diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c1c815..8571e6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## master -Nothing yet +### Fixed +- Wrong key when combining list and scalar value pointers (#110). Thanks [@daniel-sc](https://github.com/daniel-sc)
diff --git a/src/Parser.php b/src/Parser.php index 02faee1..1500f4f 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -112,6 +112,7 @@ public function getIterator() $currentPathChanged = false; $jsonPointerPath = $this->getMatchingJsonPointerPath(); $iteratorLevel = count($jsonPointerPath); + $iteratorStruct = null; } $tokenType = $tokenTypes[$token[0]]; if (0 == ($tokenType & $expectedType)) { diff --git a/test/JsonMachineTest/ParserTest.php b/test/JsonMachineTest/ParserTest.php index af12ede..3ba11e5 100644 --- a/test/JsonMachineTest/ParserTest.php +++ b/test/JsonMachineTest/ParserTest.php @@ -107,6 +107,36 @@ public function data_testSyntax() ['id' => '2'], ], ], + 'ISSUE-110-vector-first' => [ + ['/items', '/total'], + '{ + "items": [ + ["test1"], + ["test2"] + ], + "total": 2 + }', + [ + [0 => ['test1']], + [1 => ['test2']], + ['total' => 2], + ], + ], + 'ISSUE-110-scalar-first' => [ + ['/items', '/total'], + '{ + "total": 2, + "items": [ + ["test1"], + ["test2"] + ] + }', + [ + ['total' => 2], + [0 => ['test1']], + [1 => ['test2']], + ], + ], ]; }