I want to understand the basic differences clearly between Javascript object and JSON string.

Let’s say I create the following JS variable:

var testObject = {one: 1,"two":2,"three":3};

Q1. Is the key/property name valid both with/without quotes? (e.g. "one" : 1)

If yes, what is the difference?

Q2: If I convert the above object using JSON.stringify(testObject), what’s the difference between the original JS object and the JSON?

I feel they are almost the same. Please elaborate on this.

Q3: For parsing a JSON string, is the method below recommended?

var javascriptObj = JSON.parse(jSonString);

5 Answers
5

Leave a Reply

Your email address will not be published. Required fields are marked *