Javascript object Vs JSON

后端 未结 5 1028
故里飘歌
故里飘歌 2020-11-22 08:04

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

Let\'s say I create the following JS variable:

var test         


        
5条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 08:29

    Q1 - in JS you only need to use quotes if the key is a reserved word or if it would otherwise be an illegal token. In JSON you MUST always use double quotes on key names.

    Q2 - the jsonString is a serialised version of the input object ...

    Q3 - which may be deserialised to an identical looking object using JSON.parse()

提交回复
热议问题