json fieldnames spaces

会有一股神秘感。 提交于 2019-12-01 15:56:59

That's not valid JSON. JSON is a data transport format that requires field names to be string delimited with double quotes, e.g.

{
    "info" : {
        "First Name": "Robert",
        "Last Name": "Smith"
    }
}

After parsing, you can then use obj.info["First Name"] to access the First Name field.

What you have is a JS object literal (that's still invalid), but you can apply the same technique (stringify the property names) to reach the same end goal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!