jojo1981/json-path-ast-builder

dev-master 2020-03-04 21:02 UTC

This package is auto-updated.

Last update: 2024-12-05 07:10:58 UTC


README

Latest Stable Version Total Downloads License

Author: Joost Nijhuis <jnijhuis81@gmail.com>

A PHP Implementation for building an AST (Abstract Syntax Tree) from a JSON Path string.
The AST is visitable and can be visited by implementing a visitor (Behavioral Design Pattern Visitor).

Purposes of this library are:

  • Validate JSON Path syntax and give the end user a precise error message about syntax errors
  • Transform the AST into some other usable structure
  • Travers AST by implementing your own visitor

More information about JSON Path can be found here.

Installation

Library

git clone https://github.com/jojo1981/json-path-ast-builder.git

Composer

Install PHP Composer

composer require jojo1981/json-path-ast-builder

Usage

<?php

require 'vendor/autoload.php';

$astBuilder = new \Jojo1981\JsonPathAstBuilder\AstBuilder();
$ast = $astBuilder->buildAst('$.book[?(@.author==$.authors[?(@.pseudo==\'Hugo\')].name)].title');