Are multi-line strings allowed in JSON?

JSON does not allow real line-breaks. You need to replace all the line breaks with \n. eg: “first line second line” can saved with: “first line\nsecond line” Note: for Python, this should be written as: “first line\\nsecond line” where \\ is for escaping the backslash, otherwise python will treat \n as the control character “new line”

Parsing a JSON string in Ruby

This looks like JavaScript Object Notation (JSON). You can parse JSON that resides in some variable, e.g. json_string, like so: If you’re using an older Ruby, you may need to install the json gem. There are also other implementations of JSON for Ruby that may fit some use-cases better: YAJL C Bindings for Ruby JSON::Stream

Representing null in JSON

Let’s evaluate the parsing of each: http://jsfiddle.net/brandonscript/Y2dGv/ The tl;dr here: The fragment in the json2 variable is the way the JSON spec indicates null should be represented. But as always, it depends on what you’re doing — sometimes the “right” way to do it doesn’t always work for your situation. Use your judgement and make an informed decision. JSON1 {} This returns an empty … Read more

Fastest JSON reader/writer for C++

http://lloyd.github.com/yajl/ http://www.digip.org/jansson/ Don’t really know how they compare for speed, but the first one looks like the right idea for scaling to really big JSON data, since it parses only a small chunk at a time so they don’t need to hold all the data in memory at once (This can be faster or slower … Read more

Representing null in JSON

Let’s evaluate the parsing of each: http://jsfiddle.net/brandonscript/Y2dGv/ The tl;dr here: The fragment in the json2 variable is the way the JSON spec indicates null should be represented. But as always, it depends on what you’re doing — sometimes the “right” way to do it doesn’t always work for your situation. Use your judgement and make an informed decision. JSON1 {} This returns an empty … Read more

What is the difference between YAML and JSON?

Technically YAML is a superset of JSON. This means that, in theory at least, a YAML parser can understand JSON, but not necessarily the other way around. See the official specs, in the section entitled “YAML: Relation to JSON”. In general, there are certain things I like about YAML that are not available in JSON. As @jdupont … Read more