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

Default decoding structure of Parser is object

This commit is contained in:
Filip Halaxa 2022-01-08 15:24:06 +01:00
parent 3c98e16441
commit 5738c463f6
4 changed files with 8 additions and 4 deletions

View File

@ -4,6 +4,10 @@
### Removed
- Removed deprecated functions `objects()` and `httpClientChunks()`.
- Removed deprecated `JsonMachine` entrypoint class.
### Changed
- Default decoding structure of `Parser` is object. (You don't notice unless you use `Parser` class directly)
<br>
<br>

View File

@ -61,7 +61,7 @@ final class Items implements \IteratorAggregate, PositionAware
$this->bytesIterator
),
$this->jsonPointer,
$this->jsonDecoder ?: new ExtJsonDecoder(false)
$this->jsonDecoder ?: new ExtJsonDecoder()
);
}

View File

@ -64,7 +64,7 @@ class Parser implements \IteratorAggregate, PositionAware
str_replace('~1', '/', $jsonPointerPart)
);
}, explode('/', $jsonPointer)), 1);
$this->jsonDecoder = $jsonDecoder ?: new ExtJsonDecoder(true);
$this->jsonDecoder = $jsonDecoder ?: new ExtJsonDecoder();
}
/**

View File

@ -300,12 +300,12 @@ class ParserTest extends \PHPUnit_Framework_TestCase
return new Parser(new Lexer(new \ArrayIterator([$json])), $jsonPointer, new ExtJsonDecoder(true));
}
public function testDefaultDecodingStructureIsArray()
public function testDefaultDecodingStructureIsObject()
{
$items = new Parser(new Lexer(new StringChunks('[{"key": "value"}]')));
foreach ($items as $item) {
$this->assertEquals(['key' => 'value'], $item);
$this->assertEquals((object)['key' => 'value'], $item);
}
}
}