Reputation: 711
I have this JSON file
{
1 : {
name: "John Doe",
birthYear: "1990",
reqion: "USA"
phone: "604789577",
},
2 : {
name: "Jose Dirack",
birthYear: "1970",
reqion: "Europe"
phone: "768789577",
}
}
And json_decode()
is uanble to decode it.
Do you see why? Have you any idea how to fix it?
Upvotes: 0
Views: 155
Reputation: 14250
Try this:
[
{
"name": "John Doe",
"birthYear": "1990",
"reqion": "USA",
"phone": "604789577"
},
{
"name": "Jose Dirack",
"birthYear": "1970",
"reqion": "Europe",
"phone": "768789577"
}
]
Upvotes: 0
Reputation: 655239
The keys in objects need to be properly encoded strings:
{
"1" : {
"name": "John Doe",
"birthYear": "1990",
"reqion": "USA",
"phone": "604789577"
},
"2" : {
"name": "Jose Dirack",
"birthYear": "1970",
"reqion": "Europe",
"phone": "768789577"
}
}
There was also a typo with the separating commas.
Upvotes: 3