@@ -30,9 +30,10 @@ composer require remorhaz/php-json-pointer
3030Pointer utilizes JSON data accessor interfaces defined in package
3131** [ remorhaz/php-json-data] ( https://github.com/remorhaz/php-json-data ) ** . Read more about them in package documentation.
3232There is a ready-to-work implementation in that package that works with native PHP structures (like the ones you get as
33- a result of ` json_decode ` function). You can use ` RawSelectableReader ` class for read-only operations like _ test_ and
34- _ read_ , or ` RawSelectableWriter ` class for all operations. You can also implement your own accessors if you need to work
35- with another sort of data (like unparsed JSON text, for example).
33+ a result of ` json_decode ` function). You can use ` Remorhaz\JSON\Data\Reference\Reader ` class to pass values that don't
34+ need any selection or modification, or ` Remorhaz\JSON\Data\Reference\Selector ` class to select data in read-only mode,
35+ or ` Remorhaz\JSON\Data\Reference\Writer ` class to modify data. You can also implement your own accessors if you need
36+ to work with another sort of data (like unparsed JSON text, for example).
3637
3738## Using pointer
3839To access data with JSON Pointer links you need just 3 simple steps:
@@ -46,8 +47,9 @@ of accessor bound to source data for `add()` and `replace()` operations.
4647``` php
4748<?php
4849
49- use \Remorhaz\JSON\Data\RawSelectableReader;
50- use \Remorhaz\JSON\Data\RawSelectableWriter;
50+ use \Remorhaz\JSON\Data\Reference\Reader;
51+ use \Remorhaz\JSON\Data\Reference\Selector;
52+ use \Remorhaz\JSON\Data\Reference\Writer;
5153use \Remorhaz\JSON\Pointer\Pointer;
5254
5355// Setting up data.
@@ -58,29 +60,29 @@ $data = (object) [
5860];
5961
6062// Setting up read-only pointer.
61- $reader = new RawSelectableReader ($data);
63+ $reader = new Selector ($data);
6264$readPointer = new Pointer($reader);
6365
6466// Reading value.
65- echo $readPointer->read("/a/b/1")->getData (); // d
67+ echo $readPointer->read("/a/b/1")->getAsString (); // d
6668
6769// Testing value.
6870$trueResult = $readPointer->test("/a/b/1"); // Sets $trueResult to TRUE (value exists).
6971$falseResult = $readPointer->test("/a/c"); // Sets $falseResalt to FALSE (value doesn't exist).
7072
7173// Setting up writable pointer.
72- $writer = new RawSelectableWriter ($data);
74+ $writer = new Writer ($data);
7375$writePointer = new Pointer($writer);
7476
7577// Appending element to array.
7678$value = 'f';
77- $valueReader = new RawSelectableReader ($value);
79+ $valueReader = new Reader ($value);
7880$writePointer->replace("/a/b/1", $valueReader); // Sets $data->a->b to ['c', 'f', 'e'].
7981$value = 'g';
80- $valueReader = new RawSelectableReader ($value);
82+ $valueReader = new Reader ($value);
8183$writePointer->add("/a/c", $valueReader); // Adds $data->a->c property and sets it to 'g'.
8284$writePointer->remove("/a/b/0"); // Sets $data->a->b to ['f', 'e'].
8385$value = 'h';
84- $valueReader = new RawSelectableReader ($value);
86+ $valueReader = new Reader ($value);
8587$writePointer->add("/a/b/-", $valueReader); // Sets $data->a->b to ['f', 'e', 'h'].
8688```
0 commit comments