这个json字符串有什么问题?期待' EOF'}'}',',',']',得到& #39; STRING'

时间:2018-01-23 00:57:51

标签: json

    {
  "data": {
    "domains": {
"domain sample_domain_1": { 
        "name": "sample_domain_1"
      }
"domain sample_domain_11": { 
        "name": "sample_domain_11"
      }
"domain sample_domain2_11": { 
        "name": "sample_domain2_11",
        "mode": "current"
  }
"domain sample_domain2_yw": { 
        "name": "sample_domain2_yw",
        "mode": "invalid"
      }
"domain sample_domain2_y1": { 
        "name": "sample_domain2_y1"
      }
    }
  }
}

得到错误 错误:第6行的解析错误: ... e_domain_1&#34; }&#34;域sample_domai ... --------------------- ^ 期待&#39; EOF&#39;}&#39;}&#39;,&#39;,&#39;]&#39;,得到&#39; STRING&#39; < / p>

4 个答案:

答案 0 :(得分:2)

您只需要在json数据中添加逗号

{  
   "data":{  
      "domains":{  
         "domain sample_domain_1":{  
            "name":"sample_domain_1"
         },
         "domain sample_domain_11":{  
            "name":"sample_domain_11"
         },
         "domain sample_domain2_11":{  
            "name":"sample_domain2_11",
            "mode":"current"
         },
         "domain sample_domain2_yw":{  
            "name":"sample_domain2_yw",
            "mode":"invalid"
         },
         "domain sample_domain2_y1":{  
            "name":"sample_domain2_y1"
         }
      }
   }
}

答案 1 :(得分:0)

你在项目结束时错过了逗号。

enter image description here

答案 2 :(得分:0)

为了将来参考,对齐箭头将指向精确位置。

以下是jsonlint.org的格式化输出:

Error: Parse error on line 6:
..._1"              }               "domain sample_domai...
---------------------^
Expecting 'EOF', '}', ',', ']', got 'STRING'

(输出以等宽字体对齐,此处有8个空格标签。)

答案 3 :(得分:0)

您在“域名”中的每个对象的末尾都缺少“”。它应该是

{
    "data": {
        "domains": {
            "domain sample_domain_1": {
                "name": "sample_domain_1"
            },
            "domain sample_domain_11": {
                "name": "sample_domain_11"
            },
            "domain sample_domain2_11": {
                "name": "sample_domain2_11",
                "mode": "current"
            },
            "domain sample_domain2_yw": {
                "name": "sample_domain2_yw",
                "mode": "invalid"
            },
            "domain sample_domain2_y1": {
                "name": "sample_domain2_y1"
            }
        }
    }
   }