jojo1981 / json-path-ast-builder
Json Path AST builder
dev-master
2020-03-04 21:02 UTC
Requires
- php: ^7.2
- antlr/antlr4-php-runtime: ^0.3.0
- antlr4/antlr4: ^4.7
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-12-05 07:10:58 UTC
README
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
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');