Do the JSON keys have to be surrounded by quotes?

后端 未结 6 945
生来不讨喜
生来不讨喜 2020-11-22 11:23

Example: Is the following code valid against the JSON Spec?

{
    precision: \"zip\"
}

Or should I always use the following syntax? (And if

6条回答
  •  独厮守ぢ
    2020-11-22 11:54

    Yes, you need quotation marks. This is to make it simpler and to avoid having to have another escape method for javascript reserved keywords, ie {for:"foo"}.

提交回复
热议问题