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

{
    precision: "zip"
}

Or should I always use the following syntax? (And if so, why?)

{
    "precision": "zip"
}

I haven't really found something about this in the JSON specifications. Although they use quotes around their keys in their examples.

 

 


 

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"}.

 

 

原文链接

 

相关文章:

  • 2021-05-31
  • 2021-07-26
  • 2021-09-30
  • 2022-01-25
  • 2021-10-08
  • 2021-04-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2021-11-14
  • 2021-06-11
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案