Closed bhushan closed 6 months ago
Getting multiple nested content dynamically.
$json = JsonParser::parse($source)->pointer('/results/-/gender'); foreach ($json as $key => $value) { // 1st iteration: $key === 'gender', $value === 'female' // 2nd iteration: $key === 'gender', $value === 'female' // 3rd iteration: $key === 'gender', $value === 'male' // and so on for all the objects in the array... }
Same like above example we can skip any element keys after results, but we cant do that on multiple level
- $json = JsonParser::parse($source)->pointer('/results/-/gender'); + $json = JsonParser::parse($source)->pointer('/results/-/-/gender');
I understood, skipping key is only possible on array, how can we make it work with object as well?
Hi @bhushan, if you need to extract entire objects, you can simply use the /results/- JSON pointer
/results/-
Detailed description
Getting multiple nested content dynamically.
Context
Same like above example we can skip any element keys after results, but we cant do that on multiple level