I have confusion about what exactly people mean by Object Literals, JSON, JavaScript Objects, to me they seem similar:
{foo: \'bar\', bar : \'baz\'}
The variable jsonString
contains a JSON string:
var jsonString = '{"foo": "bar", "bar" : "baz"}'
The variable javascriptObject
contains a javascript object, initialized using an object literal:
var javascriptObject = {foo: 'bar', bar : 'baz'}
You can convert a json string to a javascript object with JSON.parse, and back again with JSON.stringify.