Skip to content Skip to sidebar Skip to footer

Json.parse: Expected ',' Or '}' After Property Value In Object

I keep getting this error message when I load my human.json file via AJAX. The whole error message reads JSON.parse: expected ',' or '}' after property value in object at line 2

Solution 1:

Your object isn't valid JSON. Specifically at the part:

,"female"}

A JSON property must have a value. Maybe that should that be:

,"female":{}}

or:

,"female":null}

Solution 2:

Your JSON file has a syntax error. The following is reformatted to highlight the error:

{
 "sex":{
  "male":{"fname":["Michael","Tom"]},
  "female"        <----------------- SYNTAX ERROR
 },
 "age":[16,80],
 "job":[]
}

In JSON, objects have the syntax:

{"name":"value"}

The syntax {"foo"} is invalid according to JSON spec. Therefore you need to provide some value for the female attribute:

{
 "sex":{
  "male":{"fname":["Michael","Tom"]},
  "female":{}
 },
 "age":[16,80],
 "job":[]
}

Solution 3:

Your JSON is indeed invalid.

{
  "sex": {
    "male":{
      "fname": ["Michael","Tom"]
    },
    "female"## Here is the problem
  },
  "age": [16,80],
  "job": []
}

Perhaps change that line to:

"female":{}

It all depends on what you're wanting to do

Solution 4:

your "female" is error, need a key or value

you can change the json file to

 {
"sex":{"male":{"fname":["Michael","Tom"]} ,"female":null},
 "age":[16,80],
 "job":[]
}

Solution 5:

JSON file used by you is invalid json. JSON is a collection of name/value pair. Each key in the JSON should contain value. In your case, key "Female" doesn't have any value. Below shown is the valid JSON format.

{"sex":{"male":{"fname":["Michael","Tom"]},"female":"XXX"},"age":[16,80],"job":[]

}

Post a Comment for "Json.parse: Expected ',' Or '}' After Property Value In Object"