2017 © Pedro Peláez
 

library php-json-data

JSON Data Accessors

image

remorhaz/php-json-data

JSON Data Accessors

  • Thursday, February 15, 2018
  • by remorhaz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6,858 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 13 % Grown

The README.md

PHP JSON Data Accessors

Latest Stable Version Build Status Scrutinizer Code Quality codecov Total Downloads Mutation testing badge License, (*1)

This library provides infrastructure for JSON documents processing., (*2)

Requirements

Node Values

ValueInterface can be used to represent JSON document or it's part. There is a set of descendant interfaces that provide access to typed values:, (*3)

  • ScalarValueInterface
  • ArrayValueInterface
  • ObjectValueInterface

NodeValueInterface includes information about value's path in the document, so it can be used to represent values that really exist in some JSON document. Calculated values that have no paths should implement basic ValueInterface., (*4)

Node Value Factories

This type of objects is intended to create node values from some source. This library includes two implementations of node value factories:, (*5)

  • DecodedJson\NodeValueFactory creates node value from raw PHP values (produced by json_decode() function or created manually).
  • EncodedJson\NodeValueFactory creates node value directly from encoded JSON string.

Example

<?php

use Remorhaz\JSON\Data\Value\DecodedJson;
use Remorhaz\JSON\Data\Value\EncodedJson;

// Both values represent same JSON document:
$value1 = EncodedJson\NodeValueFactory::create()->createValue('{"a":"b"}');
$value2 = DecodedJson\NodeValueFactory::create()->createValue((object) ['a' => 'b']);

Event Streams

JSON document can be represented as a stream of events. These events implement descendants of EventInterface. Such events can be emitted by any custom JSON parser, but this library also implements standard ValueWalker object that converts any NodeValueInterface to event stream., (*6)

Value walker is also able to use mutations to alter the events. There're no standard mutations, you must implement MutationInterface by yourself., (*7)

You can also use EventDecoder object to convert event stream back to NodeValueInterface., (*8)

Value exporters

Library includes a set of ValueExporterInterface implementations that allow to export ValueInterface to another representation:, (*9)

  • ValueEncoder converts value to JSON-encoded string.
  • ValueDecoder converts value to raw PHP values.

Comparators

Library includes a set of ComparatorInterface implementations that provide a simple way to compare/sort JSON documents:, (*10)

  • EqualValueComparator checks for JSON documents equality. Note that objects with same properties in different order are considered equal.
  • GreaterValueComparator compares JSON numbers and strings.
  • ContainsValueComparator checks JSON documents either for equality or for containment. Containing object is allowed to have additional properties on any level of recursion.

License

This library is licensed under the MIT License. Please see LICENSE for more information., (*11)

The Versions

15/02 2018

dev-master

9999999-dev https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Edward Surov

json

15/02 2018

v0.4.2

0.4.2.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Edward Surov

json

15/02 2018

v0.4.1

0.4.1.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Edward Surov

json

15/02 2018

v0.4.0

0.4.0.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Edward Surov

json

15/02 2018

v0.3.1

0.3.1.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Edward Surov

json

12/04 2017

v0.3.0

0.3.0.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Edward Surov

json

11/11 2016

v0.2.1

0.2.1.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Edward Surov

json

11/11 2016

v0.2.0

0.2.0.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Edward Surov

json

08/11 2016

v0.1.1

0.1.1.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Edward Surov

json

07/11 2016

v0.1.0

0.1.0.0 https://github.com/remorhaz/php-json-data

JSON Data Accessors

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Edward Surov

json