Reputation: 945
I'm trying to insert an array of strings in JSON but it isn't working.
json:
{
"1": [{
"id": "1",
"title": "test 1",
"galery": { "http://placehold.it/540x540" , "http://placehold.it/540x520"}
}]
}
It's returning me syntax error on "galery"
line but I can't figure out what is it
Upvotes: 0
Views: 276
Reputation: 628
Use [ ]
for array of images in gallery. { }
will expect object (key/value pairs).
You can check valid JSON syntax at http://www.json.org/
Upvotes: 2
Reputation: 51
You have incorrect syntax at two places. Below is the correct one:
{
"1": {
"id": "1",
"title": "test 1",
"galery": ["http://placehold.it/540x540" , "http://placehold.it/540x520"]
}
}
Upvotes: 0
Reputation: 1208
Replace the braces with brackets.
{
"1": [{
"id": "1",
"title": "test 1",
"galery": [ "http://placehold.it/540x540" , "http://placehold.it/540x520" ]
}]
}
Upvotes: 1
Reputation: 7082
For an array, use:
"galery": ["http://placehold.it/540x540", "http://placehold.it/540x520"]
For named properties, use something like:
"galery": { url1:"http://placehold.it/540x540", url2:"http://placehold.it/540x520" }
Upvotes: 2