1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-19 05:47:57 +01:00

Merge remote-tracking branch 'pr19/master'

This commit is contained in:
Filip Halaxa 2019-12-19 19:26:25 +01:00
commit c3aa1f7c62
3 changed files with 22 additions and 0 deletions

View File

@ -109,6 +109,7 @@ class Parser implements \IteratorAggregate
}
if ($currentLevel < $iteratorLevel && $inArray && $expectedType & self::ANY_VALUE) {
$currentPath[$currentLevel] = isset($currentPath[$currentLevel]) ? (string)(1+(int)$currentPath[$currentLevel]) : "0";
unset($currentPath[$currentLevel+1]);
}
switch ($firstChar) {
case '"':
@ -120,6 +121,7 @@ class Parser implements \IteratorAggregate
$jsonBuffer = '';
} elseif ($currentLevel < $iteratorLevel) {
$currentPath[$currentLevel] = json_decode($this->token);
unset($currentPath[$currentLevel+1]);
}
break;
} else {

View File

@ -0,0 +1,19 @@
{
"datafeed": {
"info": {
"category": "Category name"
},
"programs": [
{
"program_info": {
"id": "X0"
}
},
{
"program_info": {
"id": "X1"
}
}
]
}
}

View File

@ -51,6 +51,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
['/path/after-vectors', '{"path":{"array":[],"object":{},"after-vectors":{"c":1,"d":2}}}', ['c'=>1,'d'=>2]],
['/0/0', '[{"0":{"c":1,"d":2}}]', ['c'=>1,'d'=>2]],
['/1/1', '[0,{"1":{"c":1,"d":2}}]', ['c'=>1,'d'=>2]],
'PR-19-FIX' => ['/datafeed/programs/1', file_get_contents(__DIR__.'/PR-19-FIX.json'), ['program_info'=>['id'=>'X1']]],
];
}