jojo1981 / json-path-ast-builder
Json Path AST builder
1.0.0
2025-09-09 11:51 UTC
Requires
- php: ^8.0|^8.1|^8.2|^8.3|^8.4
- antlr/antlr4-php-runtime: ^0.9
- antlr4/antlr4: ^4.7
Requires (Dev)
- dg/bypass-finals: ^1.9
- phpunit/phpunit: ^9.5
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');