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:
parent
3c98e16441
commit
5738c463f6
@ -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>
|
||||
|
||||
|
@ -61,7 +61,7 @@ final class Items implements \IteratorAggregate, PositionAware
|
||||
$this->bytesIterator
|
||||
),
|
||||
$this->jsonPointer,
|
||||
$this->jsonDecoder ?: new ExtJsonDecoder(false)
|
||||
$this->jsonDecoder ?: new ExtJsonDecoder()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user