JSON格式错误

时间:2018-08-08 21:16:06

标签: json

我正在尝试构建以下JSON格式,但遇到以下错误,以下格式出了什么问题以及如何解决?

{
    project_sha_list: [{
            project: project1
            sha: sha1
        },
        {
            project: project2
            sha: sha2
        }
    ]
    train: train1
}

错误:-

Error: Parse error on line 1:
{   project_sha_list: [{
--^
Expecting 'STRING', '}', got 'undefined'

4 个答案:

答案 0 :(得分:2)

您的JSON应该是:

    {
  "project_sha_list": [
    {
      "project": "project1",
      "sha": "sha1"
    },
    {
      "project": "project2",
      "sha": "sha2"
    }
  ],
  "train": "train1"
}

您可以here对其进行验证

您的键和值都应在"

答案 1 :(得分:2)

JSON键和字符串值必须用引号括起来,如下所示,但如果该值是integer,double,long,则不应将其用引号引起来,并且如果您有多个属性,则每个属性都应以%252F结尾除了最后一个

,

答案 2 :(得分:1)

尝试这种格式:

{
    "project_sha_list": [
        {
           "project": project1,
            "sha": sha1
        },
        {
            "project": project2,
            "sha": sha2
        }
     ],
   "train": train1
 }

答案 3 :(得分:0)

正确的那教格式为:

  { 
      "project_sha_list": [
           { "project": "project1", "sha": "sha1" },
           { "project": "project2", "sha": "sha2" }
       ],
      "train": "train1" 
}