Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Machine Laravel Package

halaxa/json-machine

Efficiently parse huge JSON files and streams in PHP with low memory usage. json-machine provides an iterator-style API for incremental decoding of arrays/objects, supports JSON Lines and custom pointers/paths, and works great for imports and ETL tasks.

View on GitHub
Deep Wiki
Context7
1.2.6
  • Support for PHP 8.5
1.2.5
  • Slight performance optimization of the tokenizing process (about +7 % speed gain)
1.2.4

Fixed

1.2.3
  • 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.
1.2.2

Changed

1.2.1

Fixed

1.2.0

Added

  • Recursive iteration via new facade RecursiveItems. See Recursive iteration in README.
1.1.5

Added

  • Support for PHP 8.4
  • Exception on misspelled option name suggests a correct one.

Fixed

Removed

  • Removed support for PHP 7.0, 7.1
1.1.4
  • Minor fixes and added some tests.

Added

  • Support for PHP 8.3
  • Added PHPStan to build pipeline

Fixed

1.1.3

Fixed

1.1.2

Added

  • PHP 8.2 support

Fixed

  • Meaningful error on invalid token. (#86)
  • Added missing return type annotation. (#84)
1.1.1

Fixed

  • Fixed warning when generating autoload classmap via composer.
1.1.0

Added

1.0.1

Fixed

  • Broken command make performance-tests
  • Slight performance improvements
1.0.0

Removed

  • Removed deprecated functions objects() and httpClientChunks().
  • Removed deprecated JsonMachine entrypoint class. Use Items instead.
  • Removed deprecated Decoder interface. Use ItemDecoder instead.
  • Removed Parser::getJsonPointer(). Use Parser::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 related ValidStringResult. They are not used anymore as described in previous point.
  • PassThruDecoder does not decode keys anymore. Both the key and the value yielded are raw JSON now.

Other

  • Default decoding structure of Parser is object. (You won't notice that unless you use Parser class directly)
  • SyntaxError renamed to SyntaxErrorException
  • Items::__construct accepts the options array instead of separate arguments. (You won't notice that unless you instantiate Items class directly)
  • Lexer renamed to Tokens
  • DebugLexer renamed to TokensWithDebugging

Added

Fixed

  • Incorrect position information of TokensWithDebugging::getPosition(). Was constantly off by 1-2 bytes.
0.8.0

Changed

  • Internal decoders moved to ItemDecoder. ErrorWrappingDecoder decorator now requires ItemDecoder as well.
  • Dropped PHP 5.6 support.

Deprecated

  • JsonMachine\JsonMachine entry point class is deprecated, use JsonMachine\Items instead.
  • JsonMachine\JsonDecoder\Decoder interface is deprecated. Use JsonMachine\JsonDecoder\ItemDecoder instead.

Added

  • New entry point class Items replaces JsonMachine.
  • Object as default decoding structure instead of array in Items.
  • Items::getIterator() now returns Parser's iterator directly. Call Items::getIterator() instead of JsonMachine::getIterator()::getIterator() to get to Parser's iterator if you need it. Fixes https://stackoverflow.com/questions/63706550
  • Items uses options in its factory methods instead of growing number of many parameters. See Options in README.
  • Items introduces new debug option. See Options in README.
  • Noticeable performance improvements. What took 10 seconds in 0.7.* takes about 7 seconds in 0.8.0.
0.7.1

New features

  • PHP 8.1 support
  • DEV: Build system switched to composer scripts and Makefile
0.7.0

New features

0.6.1

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 to false. (#41 via PR #42).
0.6.0

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.
0.5.0

New features

  • Introduced FileChunks class. Takes care of the proper resource management when iterating via JsonMachine::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

  • StreamBytes and StringBytes renamed to StreamChunks and StringChunks. These are internal classes, and you probably won't notice the change unless you use them directly for some reason.
0.4.1

New features

  • Tracking of parsing progress
0.4.0

New features

BC breaks

  • ext-json is not required in composer.json anymore, 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](https://github.com/gabimem))
  • Throws UnexpectedEndSyntaxErrorException on an unexpected end of JSON structure (thanks [@gabimem](https://github.com/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 way objects() works is that it casts decoded arrays to objects. It brings some unnecessary overhead and risks on huge datasets. Alternative is to use ExtJsonDecoder which decodes items as objects by default (same as json_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.
master

Nothing yet

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4