https://github.com/apioo/psx-json
Read and transform JSON documents through JSON-Patch/Pointer
https://github.com/apioo/psx-json
json json-patch json-pointer json-rpc
Last synced: 5 months ago
JSON representation
Read and transform JSON documents through JSON-Patch/Pointer
- Host: GitHub
- URL: https://github.com/apioo/psx-json
- Owner: apioo
- License: apache-2.0
- Created: 2016-03-31T12:55:14.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-02-02T10:57:41.000Z (11 months ago)
- Last Synced: 2025-07-09T13:35:37.127Z (6 months ago)
- Topics: json, json-patch, json-pointer, json-rpc
- Language: PHP
- Homepage:
- Size: 120 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Json
## About
Library which contains classes to handle JSON data. It implements the JSON patch
and pointer specification and provides a simple JSON RPC server.
## Usage
### Patch/Pointer
```php
pointer('/author/name');
// compare whether this document is equal to another document
$document->equals(['foo' => 'bar']);
// apply patch operations on the document
$document->patch([
(object) ['op' => 'add', 'path' => '/author/uri', 'value' => 'http://google.com'],
]);
// convert the document back to a json string
echo $document->toString();
```
### RPC Server
The following example shows a super simple JSON RPC server using plain PHP.
It is also easy possible to integrate the server into any existing framework.
```php
invoke(\json_decode(file_get_contents('php://input')));
header('Content-Type: application/json');
echo \json_encode($return, JSON_PRETTY_PRINT);
```