How does JSON.parse() work?

后端 未结 4 1927
渐次进展
渐次进展 2021-02-06 09:03

I have not worked too much on javascript. And, I need to parse a JSON string. So, I want to know what exactly JSON.parse does. For example : If I assign a json string to a varia

4条回答
  •  爱一瞬间的悲伤
    2021-02-06 09:22

    A Javascript object is a data type in Javascript - it's have property and value pair as you define in your first example.

    var ab = {"name":"abcd", "details":{"address":"pqrst", "Phone":1234567890}};
    

    Now What is Json : A JSON string is a data interchange format - it is nothing more than a bunch of characters formatted a particular way (in order for different programs to communicate with each other)

    var pq = '{"name":"abcd", "details":{"address":"pqrst", "Phone":1234567890}}';
    

    so it's is a String With json Format.

    and at last JSON.parse() Returns the Object corresponding to the given JSON text.

提交回复
热议问题