4 ms·
Could someone tell me why the example given is malformed? I rarely write JSON anymore (except with json_encode in php and simplejson in python).
by cellis 17y ago
Could someone tell me why the example given is malformed? I rarely write JSON anymore (except with json_encode in php and simplejson in python).
- almost 17y agoThe malformed example given is: {foo: "bar"} which is missing the quotes around foo so it should be: {"foo": "bar"} Since both of those would have had the same meaning the JSON spec sensibly restricts things so that only one is valid. See http://json.org/ http://json.org/ for the (very short and readable) spec.
- ionfish 17y agoThe object property is assigned with a name, not a (double-quoted) string. Well-formed JSON would look like this: {"foo": "bar"}