Download the PHP package webdevcraft/jsonreader without Composer

On this page you can find all versions of the php package webdevcraft/jsonreader. 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 jsonreader

JsonReader

Build Status

JSON streaming reader (memory safety parser) with chunking option

Purpose and Advantages

  1. Memory safety read of huge JSON files: solve "out of RAM" problem. Successfully tested with 1.5Gb JSON files
  2. Possibility to split large JSON file to smaller JSON chunks
  3. Custom traverse through JSON tree
  4. Read any JSON source: file, string, resource, character iterator
  5. Installation with Composer, no need any extra PHP extensions

Requirements

PHP 5.6, 7.0

Installation

With Composer:

Basic Usage

JSON Reader iterates through JSON structure elements

Each iterates to next element until it returns false when finished

So common usage is:

Reader provides information on each element:

  1. DEPTH in JSON tree starting from 1:

  2. STATE (type of element): . There is syntax sugar issers exist for each of states. State could be one of:

    • Object Start: _JsonReaderInterface::STATE_OBJECTSTART (or )

    • Object Key: _JsonReaderInterface::STATE_OBJECTKEY (or )

    • Object End _JsonReaderInterface::STATE_OBJECTEND (or )

    • Array Start _JsonReaderInterface::STATE_ARRAYSTART (or )

    • Array End _JsonReaderInterface::STATE_ARRAYEND (or )

    • Value _JsonReaderInterface::STATEVALUE (or )
  3. VALUE of element by . Types:

    1. For the type of value is automatically casted to PHP type: string, int, float, boolean, null

    2. For state is always string

    3. For other states value is always null

Example of elements sequence for test.json is presented in JsonReaderTest.php::testReadTokens()

Chunks Usage

In case if your code is already dependent on JSON string denormanization you could use JsonReader library for chunking of huge file onto smaller JSON strings

Just start buffering chunk on element position you wish by and get chunk by . That returnes JSON chunk string and flushes buffer.

As chunk is buffered in memory make sure your JSON schema guarantees acceptable size of chunk

That's nice practice to wrap chunks retrieve to iterator

Example of test.json chunking is presented in JsonReaderTest.php::testChunks()

Factory Usage

To create reader you have to use JsonReaderFactory

Example of JsonReader creating:

Factory supports any sources by such methods:

  1. createByFilePath by file path in local filesystem
  2. createByString by JSON string passing
  3. createByResource by opened resource link, for example with fopen()
  4. createByCharacterTraversable - if options above do not suite your needs feel free to write your custom characters iterator using any source you have to deal with. For example you could iterate PSR-7 Message\StreamInterface::read($acceptableSize) and iterate characters inside each of read()

Example of characters iterators


All versions of jsonreader with dependencies

PHP Build Version
Package Version
No informations.
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 webdevcraft/jsonreader contains the following files

Loading the files please wait ....