user3508811
user3508811

Reputation: 925

Incorrect JSON format

I am trying to construct a JSON formats follows but running into below error, what is wrong with the below format and how to fix it?

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

ERROR:-

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

Upvotes: -1

Views: 254

Answers (4)

Ryuzaki L
Ryuzaki L

Reputation: 40078

JSON keys and string values must be in quotes like below, but if the value is integer,double,long then it should not be enclosed in quotes, and if you have multiple properties each property should end with , except last one

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

Upvotes: 2

Ajay Kumar
Ajay Kumar

Reputation: 97

The correct jain format is:

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

Upvotes: 0

Shan-Desai
Shan-Desai

Reputation: 3349

Your JSON should be:

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

You can validate it here

you keys and values both should be within "

Upvotes: 1

Moshe
Moshe

Reputation: 2684

Try this format:

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

Upvotes: 0

Related Questions