Download the PHP package umulmrum/json-parser without Composer

On this page you can find all versions of the php package umulmrum/json-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-parser

JSON Parser

JSON Parser is a streaming JSON parsing library. It returns the same results as \json_decode('some-string', true, 512, JSON_UNESCAPED_SLASHES).

You might want to use this library when decoding JSON that is multiple MiB in size, where the in-memory approach of \json_decode() consumes excessive amounts of memory. This library has constant memory usage independent of the size of the JSON string if used correctly (which is not difficult, see below).

You might NOT want to use this library for small JSON strings of less than ~1 MiB, as \json_decode() is about 50x faster. While I aim for performance improvements, the C implementation of \json_decode() will always be faster than this PHP implementation.

Latest Stable Version Latest Unstable Version License Build Status

Requirements

That's it really. However, using the mb_string extension will improve performance.

Installation

Install the library using Composer.

Status

This library is in beta state. Code coverage in unit tests is high and the library is already used in production, but it is not yet considered stable; you are encouraged to test it and report issues.

Usage

Every valid JSON string consists of either a root array or a root object containing values. The generate() method returns these first-level values, one at a time. Each returned value is a PHP array containing a single key/value pair; the key is

These values can then be consumed (e.g. persisted, printed or sent by AMQP) and be discarded afterwards.

If the JSON string consists of an empty object or array, an empty array is returned.

If the JSON string is empty or consists only of whitespace, null is returned.

On errors, one of these exceptions is thrown:

If no exception was thrown, the result can be "trusted" (i.e. there is no need to check for errors afterwards such as \json_last_error()).

Alternative Usage

Alternatively, instantiate the parser from a JSON string:

Be aware that this will not be very memory-efficient as PHP uses a lot of memory for strings. Whenever possible, the fromFile() factory method is recommended.

JsonParser can also return the complete content by calling all() (which is again not recommended because of memory).

Customization

Internally, JsonParser uses an implementation of \Umulmrum\JsonParser\DataSource\DataSourceInterface to receive the characters to parse. The factory methods for JsonParser are simple convenience methods that handle instantiating the data source, but the constructor can be called manually, passing a data source, so that custom data source implementations can be used. See the docblocks of \Umulmrum\JsonParser\DataSource\DataSourceInterface for details. You might wish to extend \Umulmrum\JsonParser\DataSource\AbstractDataSource that contains some convenience methods.

The example from the previous section can be written as follows:

Backwards Compatibility

This library follows Semantic Versioning and will therefore only introduce breaking changes in the public API in major versions (and in minor versions before reaching 1.0.0). The public API consists of all classes, except

Contribution

Contributions are highly welcome. Please follow these rules when submitting a PR:

By submitting a PR you agree that all your contributed code may be used under the MIT license.

License

This library is licensed under the MIT License. See LICENSE for details.


All versions of json-parser with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
symfony/polyfill-mbstring Version ~1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package umulmrum/json-parser contains the following files

Loading the files please wait ...