json-machine
json-machine copied to clipboard
Wildcard pointer doesn't work properly
Hello!
I have a problem to using wildcard pointer /results/-/color like in example from root documentation:
as result I receive only 1st iteration and second is not available through the foreach or iterator
$fruits = Items::fromFile('fruitsArray.json', ['pointer' => '/results/-/color']);
- my code example below:
<?php
$json = '{"results":[{"name":"apple","color":"red"},{"name":"pear","color":"yellow"},{"name":"some","color":"green"}]}';
$fruits = Items::fromString($json, ['pointer' => "/results/-/color"]);
var_dump(iterator_count($fruits->getIterator())); // result 1
foreach ($fruits as $key => $value) {
echo "{$value}\n"; // result only red
}
- also trying to pass the test of package and it's good
- package version is 1.1.1
P.S: Your library is awesome)
Hi, thanks for pointing that out. Are you able to add a failing test case? If so, add it as a case in \JsonMachineTest\ParserTest::data_testSyntax. Thanks.
Hi @antonMilukov, does #83 solve your problem?
Can this be closed, @antonMilukov ?
Closing for now. Feel free to comment if the problem persists.