Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4612

When to use dump vs. generate vs. to_json and load vs. parse in Ruby's JSON lib?

$
0
0

david4dev's answer to this question claims that there are three equivalent ways to convert an object to a JSON string using the json library:

JSON.dump(object)JSON.generate(object)object.to_json

and two equivalent ways to convert a JSON string to an object:

JSON.load(string)JSON.parse(string)

But looking at the source code, each of them seems to be pretty much different, and there are some differences between them (e.g., 1).

What are the differences among them? When to use which?


Viewing all articles
Browse latest Browse all 4612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>