All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Nothing yet
- Support for PHP 8.5
- Slight performance optimization of the tokenizing process (about +7 % speed gain)
- The key of a scalar value after a compound value is lost (#125). Thanks @smiletoeverybody
- Tokenizer completely rewritten to use regular expressions for partial tokenization. Got rid of per-byte processing in PHP code. Standard parsing speed boost (non-recursive, non-debug) about + 50 %. Further improvements on the way.
- Leaner release package (#124). Thanks @robotomarvin
- File autoloading without composer (#122). Thanks @bahco
- Crash on
nullvalue inRecursiveItems(#119). Thanks @bark92
- Recursive iteration via new facade
RecursiveItems. See Recursive iteration in README.
- Support for PHP 8.4
- Exception on misspelled option name suggests a correct one.
- Wrong key when combining list and scalar value pointers (#110). Thanks @daniel-sc
- Removed support for PHP 7.0, 7.1
- Minor fixes and added some tests.
- Support for PHP 8.3
- Added PHPStan to build pipeline
- Fixed the case when non-intersecting pointers were considered intersecting (#106). Thanks @XedinUnknown
- Fix the parsing of nested sub-trees that use wildcards (#83). Thanks @cerbero90
- PHP 8.2 support
- Fixed warning when generating autoload classmap via composer.
- Autoloading without Composer. Thanks @a-sync.
- Broken command
make performance-tests - Slight performance improvements
- Removed deprecated functions
objects()andhttpClientChunks(). - Removed deprecated
JsonMachineentrypoint class. UseItemsinstead. - Removed deprecated
Decoderinterface. UseItemDecoderinstead. - Removed
Parser::getJsonPointer(). UseParser::getJsonPointers()/Items::getJsonPointers()instead. - Removed
Parser::getJsonPointerPath(). No replacement. Was not useful for anything other than testing and exposed internal implementation.
- JSON Pointer parts between slashes (a.k.a reference tokens) must be valid encoded JSON strings to be JSON Pointer RFC 6901 compliant. It means that no internal key decoding is performed anymore. You will have to change your JSON Pointers if you match against keys with escape sequences.
Items::fromString(
'{"quotes\"": [1, 2, 3]}',
- ['pointer' => '/quotes"']
+ ['pointer' => '/quotes\"']
);- Method
ItemDecoder::decodeInternalKey()was deleted as well as relatedValidStringResult. They are not used anymore as described in previous point. PassThruDecoderdoes not decode keys anymore. Both the key and the value yielded are raw JSON now.
- Default decoding structure of
Parseris object. (You won't notice that unless you useParserclass directly) SyntaxErrorrenamed toSyntaxErrorExceptionItems::__constructaccepts the options array instead of separate arguments. (You won't notice that unless you instantiateItemsclass directly)Lexerrenamed toTokensDebugLexerrenamed toTokensWithDebugging
- Multiple JSON Pointers can be specified as an array in
pointeroption. See README. Thanks @fwolfsjaeger. - New methods available during iteration:
Items::getCurrentJsonPointer()andItems::getMatchedJsonPointer()to track where you are. See README. Thanks @fwolfsjaeger.
- Incorrect position information of
TokensWithDebugging::getPosition(). Was constantly off by 1-2 bytes.
- Internal decoders moved to
ItemDecoder.ErrorWrappingDecoderdecorator now requiresItemDecoderas well. - Dropped PHP 5.6 support.
JsonMachine\JsonMachineentry point class is deprecated, useJsonMachine\Itemsinstead.JsonMachine\JsonDecoder\Decoderinterface is deprecated. UseJsonMachine\JsonDecoder\ItemDecoderinstead.
- New entry point class
ItemsreplacesJsonMachine. - Object as default decoding structure instead of array in
Items. Items::getIterator()now returnsParser's iterator directly. CallItems::getIterator()instead ofJsonMachine::getIterator()::getIterator()to get toParser's iterator if you need it. Fixes https://stackoverflow.com/questions/63706550Itemsusesoptionsin its factory methods instead of growing number of many parameters. See Options in README.Itemsintroduces newdebugoption. See Options in README.- Noticeable performance improvements. What took 10 seconds in
0.7.*takes about 7 seconds in0.8.0.
- PHP 8.1 support
- DEV: Build system switched to composer scripts and Makefile
- Use a
-in json pointer as a wildcard for an array index. Example:/users/-/id. Thanks @cerbero90
- Empty dict at the end of an item was causing Syntax error in the next item. Reason: closing
}did not set object key expectation tofalse. (#41 via PR #42).
- New: Json pointer can find scalar values in JSON document as well as iterable values. See Getting single scalar values
- Parser ends when the end of the desired data is reached and does not heat up the atmosphere further.
- Optimizations: about 15% speed gain.
- A json pointer that matches scalar value does not throw anymore, but the scalar value is yielded in foreach.
- Introduced
FileChunksclass. Takes care of the proper resource management when iterating viaJsonMachine::fromFile(). It is used internally, and you probably won't come across it. - New
ErrorWrappingDecoder. Use it when you want to skip malformed JSON items. See Decoders.
StreamBytesandStringBytesrenamed toStreamChunksandStringChunks. These are internal classes, and you probably won't notice the change unless you use them directly for some reason.
- Tracking of parsing progress
- Decoders
- PHP 8 support (thanks @snapshotpl)
ext-jsonis not required incomposer.jsonanymore, because custom decoder might not need it. However built-in decoders depend on it so it must be present if you use them.- All exceptions now extend
JsonMachineException(thanks @gabimem) - Throws
UnexpectedEndSyntaxErrorExceptionon an unexpected end of JSON structure (thanks @gabimem) - Function
httpClientChunks()is deprecated so that compatibility with Symfony HttpClient is not on the shoulders of JSON Machine maintainer. The code is simple and everyone can make their own function and maintain it. The code was moved to examples. - Function
objects()is deprecated. The wayobjects()works is that it casts decoded arrays to objects. It brings some unnecessary overhead and risks on huge datasets. Alternative is to useExtJsonDecoderwhich decodes items as objects by default (same asjson_decode).
<?php
use JsonMachine\JsonDecoder\ExtJsonDecoder;
use JsonMachine\JsonMachine;
$jsonMachine = JsonMachine::fromFile('path/to.json', '', new ExtJsonDecoder);Therefore no additional casting is required.
- Invalid json object keys will now throw and won't be ignored anymore.
- Decoding of json object keys checks for errors and does not silently ignore them.