bus-factor / json-pointer
JSON pointer (RFC 6901: https://datatracker.ietf.org/doc/html/rfc6901) library
v0.0.3
2023-04-25 21:55 UTC
Requires
- php: ^8.2
- ext-mbstring: *
README
This library provides an implementation of RFC-6901 (JavaScript Object Notation (JSON) Pointer).
Usage
namespace BusFactor\JsonPointer; interface PointerInterface extends Stringable { /** * @param array<string|int> $referenceTokens */ public function __construct(array $referenceTokens = []); /** * @return array<string|int> */ public function getReferenceTokens(): array; public function append(string|int $referenceToken): static; public function prepend(string|int $referenceToken): static; public static function fromJson(string $json): static; public function toJson(): string; }
Mutable pointer
$pointer = new \BusFactor\JsonPointer\Pointer(['data', 'users', '1']);
Immutable pointer
$immutablePointer = new \BusFactor\JsonPointer\ImmutablePointer(['data', 'users', '1']);