1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-29 10:28:09 +01:00

Fixed double key yield

This commit is contained in:
Filip Halaxa 2018-11-07 19:37:19 +01:00
parent 6b169b17b1
commit a73654cd65
2 changed files with 6 additions and 2 deletions

View File

@ -120,6 +120,7 @@ class Parser implements \IteratorAggregate
$previousToken = null;
if ($currentLevel === $iteratorLevel) {
$key = $token;
$jsonBuffer = '';
} elseif ($currentLevel < $iteratorLevel) {
$currentPath[$currentLevel] = json_decode($token);
}

View File

@ -15,8 +15,11 @@ class ParserTest extends \PHPUnit_Framework_TestCase
*/
public function testSyntax($pathSpec, $json, $expectedResult)
{
$result = iterator_to_array($this->createParser($json, $pathSpec));
$this->assertEquals($expectedResult, $result);
$resultWithKeys = iterator_to_array($this->createParser($json, $pathSpec));
$resultNoKeys = iterator_to_array($this->createParser($json, $pathSpec), false);
$this->assertEquals($expectedResult, $resultWithKeys);
$this->assertEquals(array_values($expectedResult), $resultNoKeys);
}
public function dataSyntax()