Hi there and first of all, thank you for this amazing parser. A true life saver.
I'm currently trying to fully understand how it works, but have run into a problem that I can't really figure out how to solve.
[
{
"id": 2584,
"name": "John",
"parentCategory": 2570,
"url": "john",
"dateUpd": "2016-06-23 14:27:32",
"dateAdd": "2016-05-13 11:33:35",
"urlImages": [
"http://imageurl.com/2584_header.jpg",
"http://imageurl.com/2584_menu.jpg",
"http://imageurl.com/2584_mini.jpg"
],
"isoCode": "sv"
},
{
"id": 2429,
"name": "Carol",
"parentCategory": 2570,
"url": "carol",
"dateUpd": "2016-06-23 14:33:36",
"dateAdd": "2016-05-13 10:11:30",
"urlImages": [
"http://imageurl.com/2429_header.jpg",
"http://imageurl.com/2429_menu.jpg",
"http://imageurl.com/2429_mini.jpg"
],
"isoCode": "sv"
},
{
"id": 2568,
"name": "Andy",
"parentCategory": 2552,
"url": "andy",
"dateUpd": "2016-06-23 13:55:13",
"dateAdd": "2016-05-13 11:29:32",
"urlImages": [
"http://imageurl.com/2568_header.jpg",
"http://imageurl.com/2568_menu.jpg",
"http://imageurl.com/2568_mini.jpg"
],
"isoCode": "sv"
}
]
$reader = new JsonReader();
$reader->json($json);
while($reader->read("parentCategory")) {
$parentID = $reader->value();
if ($parentID == 2570) {
echo $reader->value()."\n";
}
}
$reader->close();
This prints the parentCategory ID, but what I need is to be able to use the parentCategory name and value to identify the whole object it belongs to and in the end return the following:
[
{
"id": 2584,
"name": "John",
"parentCategory": 2570,
"url": "john",
"dateUpd": "2016-06-23 14:27:32",
"dateAdd": "2016-05-13 11:33:35",
"urlImages": [
"http://imageurl.com/2584_header.jpg",
"http://imageurl.com/2584_menu.jpg",
"http://imageurl.com/2584_mini.jpg"
],
"isoCode": "sv"
},
{
"id": 2429,
"name": "Carol",
"parentCategory": 2570,
"url": "carol",
"dateUpd": "2016-06-23 14:33:36",
"dateAdd": "2016-05-13 10:11:30",
"urlImages": [
"http://imageurl.com/2429_header.jpg",
"http://imageurl.com/2429_menu.jpg",
"http://imageurl.com/2429_mini.jpg"
],
"isoCode": "sv"
}
]