JSON Parse Error: Expecting 'STRING'

后端 未结 3 1031
借酒劲吻你
借酒劲吻你 2021-02-12 21:57

I am using JSONLint to parse some JSON and i keep getting the error:

Error: Parse error on line 1: [{“ product”: [{“
---^ Expecting \'STRING

相关标签:
3条回答
  • 2021-02-12 22:28

    JSON string literals must use normal quote characters ("), not smart quotes (“”).

    0 讨论(0)
  • 2021-02-12 22:37

    You're using some unicode double quotes characters. Replace them with the normal " double quotes.

    You also had some extra comma at the end in the second element.

    Now it's alright

    [
        {
            "product" :  [ { "code" : "Abc123", "description" : "Saw blade", "price" : 34.95 } ],
            "vendor" : [ { "name" : "Acme Hardware", "state" : "New Jersey" } ]
        },
    
        {
            "product" :  [ { "code" : "Def456", "description" : "Hammer", "price" : 22.51 } ]
        },
        {
            "product" :  [ { "code" : "Ghi789", "description" : "Wrench", "price" : 12.15 } ],
            "vendor" : [ { "name" : "Acme Hardware", "state" : "New Jersey" } ]
        },
        {
            "product" : [ { "code" : "Jkl012", "description" : "Pliers", "price" : 14.54 } ],
            "vendor" : [ { "name" : "Norwegian Tool Suppliers", "state" : "Kentucky" } ]
        }
    ]
    
    0 讨论(0)
  • 2021-02-12 22:49

    JSON must use normal quote characters("), not smart quotes for(“”) for string literals.

    To get the normal quote in JSON data format: right-click on browser window and select - view page source.

    0 讨论(0)
提交回复
热议问题