Hey there!
I need to get some specific data out of a JSON string. I've used the miva_json_decode function before and quite like it. But this time the JSON data I'm using is nested, and this seems to be a problem for the miva_json_decode function.
Here's an example of what the nested data I'm working with looks like:
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}
The function does not return 1, aka it cannot seem to parse it. Any suggestions?
EDIT: Sorry formatting on the json data didn't keep spacing. Copy paste that into a JSON beautifier if it helps you to be able to see the cascading.
Thanks in advance!
Jaime
I need to get some specific data out of a JSON string. I've used the miva_json_decode function before and quite like it. But this time the JSON data I'm using is nested, and this seems to be a problem for the miva_json_decode function.
Here's an example of what the nested data I'm working with looks like:
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}
The function does not return 1, aka it cannot seem to parse it. Any suggestions?
EDIT: Sorry formatting on the json data didn't keep spacing. Copy paste that into a JSON beautifier if it helps you to be able to see the cascading.
Thanks in advance!
Jaime
Comment