2017 © Pedro Peláez
 

library json

Read and transform JSON documents through JSON-Patch/Pointer

image

psx/json

Read and transform JSON documents through JSON-Patch/Pointer

  • Thursday, June 1, 2017
  • by k42b3
  • Repository
  • 1 Watchers
  • 2 Stars
  • 22,130 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 14 % Grown

The README.md

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., (*1)

Usage

Patch/Pointer

<?php

$document = Document::from(\json_decode(\file_get_contents('/test.json')));
// or
$document = Document::from(\json_decode('{"author": {"name": "foo"}}'));

// get a value through a json pointer
$name = $document->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., (*2)

<?php

use PSX\Json\RPC\Server;
use PSX\Json\RPC\Exception\MethodNotFoundException;

$server = new Server(function($method, $arguments){
    if ($method === 'sum') {
        return array_sum($arguments);
    } else {
        throw new MethodNotFoundException('Method not found');
    }
});

$return = $server->invoke(\json_decode(file_get_contents('php://input')));

header('Content-Type: application/json');
echo \json_encode($return, JSON_PRETTY_PRINT);

The Versions

01/06 2017

dev-master

9999999-dev http://phpsx.org

Read and transform JSON documents through JSON-Patch/Pointer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json patch pointer

09/12 2016

v1.0.3

1.0.3.0 http://phpsx.org

Read and transform JSON documents through JSON-Patch/Pointer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json patch pointer

30/07 2016

v1.0.2

1.0.2.0 http://phpsx.org

Read and transform JSON documents through JSON-Patch/Pointer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json patch pointer

10/07 2016

v1.0.1

1.0.1.0 http://phpsx.org

Handle JSON patch, pointer and web token specifications

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json patch pointer web-token

08/05 2016

v1.0.0

1.0.0.0 http://phpsx.org

Handle JSON patch, pointer and web token specifications

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json patch pointer web-token

03/04 2016

v0.1.2

0.1.2.0 http://phpsx.org

Handle JSON patch, pointer and web token specifications

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json patch pointer web-token

02/04 2016

v0.1.1

0.1.1.0 http://phpsx.org

Handle JSON patch, pointer and web token specifications

  Sources   Download

Apache-2.0

The Requires

  • php >=5.5

 

The Development Requires

json patch pointer web-token

02/04 2016

v0.1.0

0.1.0.0 http://phpsx.org

Handle JSON patch, pointer and web token specifications

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

json patch pointer web-token