I have the following JSON object:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
0: Object
category: Object
0: "Value"
I was wondering how I could get 'Value' in a variable in PHP. I thought category[0] would just do it but I get the following instead of 'Value':
__proto__: Object
What should I do?
asked Nov 11, 2013 at 20:13
Anoniem Anoniem
2,0156 gold badges19 silver badges19 bronze badges
1 Answer 1
You have to converts the JSON string into associative array, which is done by json_decode() with second parameter set as true.
$var = json_decode($json, true);
$value = $var['0']['category']['0'];
answered Nov 11, 2013 at 22:30
Ladislav M
2,1854 gold badges37 silver badges52 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-php
$var = json_decode($json); $var[0]['category']['0']