halaxa/json-machine
Efficient, easy-to-use and fast JSON pull parser
1.2.6
27M downloads/mo
#674 most downloaded on Packagist
halaxa/json-machine
What this package is like to depend on
Last release 8 months ago
05 Dec 2025
Release timing varies
gaps range from 2 weeks to 1.1 years
Most releases are documented
notes for 23 of 30 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
32 releases · first in 2018
1 release in the last 12 months
see the full history below
Release timeline
32 releases · Nov 2018 to Dec 2025Releases
latest 32-
1.2.605 Dec 2025 -
1.2.507 Jul 2025Release notes
Open source →- Slight performance optimization of the tokenizing process (about +7 % speed gain)
<br>
-
1.2.416 Jun 2025Release notes
Open source →Fixed
- The key of a scalar value after a compound value is lost (#125). Thanks @smiletoeverybody
<br>
-
1.2.330 May 2025Release notes
Open source →- 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.
<br>
-
1.2.230 Apr 2025 -
1.2.125 Apr 2025 -
1.2.024 Nov 2024Release notes
Open source →Added
- Recursive iteration via new facade
RecursiveItems. See Recursive iteration in README.
<br>
- Recursive iteration via new facade
-
1.1.522 Nov 2024Release notes
Open source →Added
- Support for PHP 8.4
- Exception on misspelled option name suggests a correct one.
Fixed
- Wrong key when combining list and scalar value pointers (#110). Thanks @daniel-sc
Removed
- Removed support for PHP 7.0, 7.1 <br>
-
1.1.428 Nov 2023Release notes
Open source →- Minor fixes and added some tests.
Added
- Support for PHP 8.3
- Added PHPStan to build pipeline
Fixed
- Fixed the case when non-intersecting pointers were considered intersecting (#106). Thanks @XedinUnknown
<br>
-
1.1.312 Oct 2022Release notes
Open source → -
1.1.229 Sep 2022 -
1.1.103 Mar 2022Release notes
Open source →Fixed
- Fixed warning when generating autoload classmap via composer.
<br>
-
1.1.019 Feb 2022 -
1.0.105 Feb 2022Release notes
Open source →Fixed
- Broken command
make performance-tests - Slight performance improvements
<br>
- Broken command
-
1.0.004 Feb 2022Release notes
Open source →Removed
- 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.
Changed
Simplified and fixed decoding
- 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.
Other
- 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
Added
- 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.
Fixed
- Incorrect position information of
TokensWithDebugging::getPosition(). Was constantly off by 1-2 bytes.
<br>
- Removed deprecated functions
-
0.8.007 Jan 2022Release notes
Open source →Changed
- Internal decoders moved to
ItemDecoder.ErrorWrappingDecoderdecorator now requiresItemDecoderas well. - Dropped PHP 5.6 support.
Deprecated
JsonMachine\JsonMachineentry point class is deprecated, useJsonMachine\Itemsinstead.JsonMachine\JsonDecoder\Decoderinterface is deprecated. UseJsonMachine\JsonDecoder\ItemDecoderinstead.
Added
- 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.
<br>
- Internal decoders moved to
-
0.8.0-BETA204 Jan 2022 pre-releaseNothing published for this version
-
0.8.0-BETA24 Dec 2021 pre-releaseNothing published for this version
-
0.7.106 Dec 2021Release notes
Open source →New features
- PHP 8.1 support
- DEV: Build system switched to composer scripts and Makefile
<br>
-
0.7.006 May 2021Release notes
Open source →New features
- Use a
-in json pointer as a wildcard for an array index. Example:/users/-/id. Thanks @cerbero90
<br>
- Use a
-
0.6.106 Apr 2021Release notes
Open source →Fixed bugs
- 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).
<br>
- Empty dict at the end of an item was causing Syntax error in the next item. Reason: closing
-
0.6.024 Jan 2021Release notes
Open source →New features
- 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.
BC breaks
- A json pointer that matches scalar value does not throw anymore, but the scalar value is yielded in foreach.
<br>
-
0.5.008 Dec 2020Release notes
Open source →New features
- 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.
BC breaks
StreamBytesandStringBytesrenamed toStreamChunksandStringChunks. These are internal classes, and you probably won't notice the change unless you use them directly for some reason.
<br>
- Introduced
-
0.4.101 Dec 2020 -
0.4.009 Nov 2020Release notes
Open source →New features
- Decoders
- PHP 8 support (thanks @snapshotpl)
BC breaks
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.
Fixed bugs
- Decoding of json object keys checks for errors and does not silently ignore them.
-
0.3.320 Dec 2019Nothing published for this version
-
0.3.220 Mar 2019Nothing published for this version
-
0.3.116 Mar 2019Nothing published for this version
-
0.3.013 Dec 2018Nothing published for this version
-
v0.2.129 Nov 2018Nothing published for this version
-
v0.2.029 Nov 2018Nothing published for this version
-
v0.1.012 Nov 2018Nothing published for this version