I've got a small piece of JSON that I needed parsed. I want to retrieve only one specific field. I used the miva_json_decode(input, output) function to do the first part of the job.
Here's tan example piece of JSON data:
{
"data": [{
"id": 535819,
"item_id": 114292,
"warehouse_id": 1,
"obtainable": 0,
"created_at": "2017-07-28 16:29:42",
"updated_at": "2017-07-28 16:29:42"
}]
}
It seems to parse fine, as there are no errors received when I use miva_json_decode_last_error(). When I display the entire output, it shows all the contents just fine (though out of order) like so:
2017-07-28 16:29:42,535819,114292,0,2017-07-28 16:29:42,1
The issue arises when trying to access a specific element of this array. The docs say the function outputs as a structured array.But I can't find any documentation on how it structures the array whatsoever. I've just been trying an endless combination of indexes, and member names but I can't seem to access any of the elements.
I tried miva_array_max and min to try and figure out how it's structured. But this returns -1 for both, an impossible index. So I'm confused as to how miva_json_decode REALLY outputs!
Any info would be helpful.
Thank You in Advance,
Jaime
Here's tan example piece of JSON data:
{
"data": [{
"id": 535819,
"item_id": 114292,
"warehouse_id": 1,
"obtainable": 0,
"created_at": "2017-07-28 16:29:42",
"updated_at": "2017-07-28 16:29:42"
}]
}
It seems to parse fine, as there are no errors received when I use miva_json_decode_last_error(). When I display the entire output, it shows all the contents just fine (though out of order) like so:
2017-07-28 16:29:42,535819,114292,0,2017-07-28 16:29:42,1
The issue arises when trying to access a specific element of this array. The docs say the function outputs as a structured array.But I can't find any documentation on how it structures the array whatsoever. I've just been trying an endless combination of indexes, and member names but I can't seem to access any of the elements.
I tried miva_array_max and min to try and figure out how it's structured. But this returns -1 for both, an impossible index. So I'm confused as to how miva_json_decode REALLY outputs!
Any info would be helpful.
Thank You in Advance,
Jaime
Comment