PHPackages                             remorhaz/php-json-data - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. remorhaz/php-json-data

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

remorhaz/php-json-data
======================

JSON Data Accessors

v0.7.0(2y ago)0618.0k↓61.2%4[2 PRs](https://github.com/remorhaz/php-json-data/pulls)4MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0CI failing

Since Nov 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/remorhaz/php-json-data)[ Packagist](https://packagist.org/packages/remorhaz/php-json-data)[ Docs](https://github.com/remorhaz/php-json-data)[ RSS](/packages/remorhaz-php-json-data/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (17)Used By (4)

PHP JSON Data Accessors
=======================

[](#php-json-data-accessors)

[![Latest Stable Version](https://camo.githubusercontent.com/0f1e7c5e8eb69d84d6e9908feea7dc84a60e0b2bb2d85922ca2078a2cbb39a9c/68747470733a2f2f706f7365722e707567782e6f72672f72656d6f7268617a2f7068702d6a736f6e2d646174612f762f737461626c65)](https://packagist.org/packages/remorhaz/php-json-data)[![Build Status](https://camo.githubusercontent.com/b662d105c680388f1770515ba6e7ef87f17b16aa78122380be610cf963a14ed4/68747470733a2f2f7472617669732d63692e6f72672f72656d6f7268617a2f7068702d6a736f6e2d646174612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/remorhaz/php-json-data)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dcb0a9c8d60a8c606d2d40ccc62297dec2e1fa5a06fe20abd298e16f553ff4d2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f72656d6f7268617a2f7068702d6a736f6e2d646174612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/remorhaz/php-json-data/?branch=master)[![codecov](https://camo.githubusercontent.com/cda669c1dc2d8d0307dad1a726601de7d641eb0e91d026aca74270034567d94c/68747470733a2f2f636f6465636f762e696f2f67682f72656d6f7268617a2f7068702d6a736f6e2d646174612f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/remorhaz/php-json-data)[![Total Downloads](https://camo.githubusercontent.com/b0473de01c145e35822c1c31a864b8e2f328e1cc4a8110e7038183568f162264/68747470733a2f2f706f7365722e707567782e6f72672f72656d6f7268617a2f7068702d6a736f6e2d646174612f646f776e6c6f616473)](https://packagist.org/packages/remorhaz/php-json-data)[![Mutation testing badge](https://camo.githubusercontent.com/210cac3cc74a931c31be20431c65f8e53eb8b2b4254717e739a5df18e994242a/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324672656d6f7268617a2532467068702d6a736f6e2d646174612532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/remorhaz/php-json-data/master)[![License](https://camo.githubusercontent.com/ea04fcaca507f966cc1eabe24dcfcbf43538a9e0a0c73d68d76548dfa70e29fe/68747470733a2f2f706f7365722e707567782e6f72672f72656d6f7268617a2f7068702d6a736f6e2d646174612f6c6963656e7365)](https://packagist.org/packages/remorhaz/php-json-data)

This library provides infrastructure for JSON documents processing.

Requirements
------------

[](#requirements)

- PHP 8.1 or newer.
- [Internationalization functions](https://www.php.net/manual/en/book.intl.php) (ext-intl) - to compare Unicode strings.
- [JSON extension](https://www.php.net/manual/en/book.json.php) (ext-json) - to encode and decode JSON documents.

Node Values
-----------

[](#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:

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

Node Value Factories
--------------------

[](#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:

- `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

[](#example)

```
