Implements the jq syntax in Rust, providing an abstract syntax tree.
Use it like this in your program:
```rust use jqlang::toast; use jqlang::nodetype::NodeType;
let ast = toast(".").unwrap(); asserteq!(ast.node_type, NodeType::Program); ```
The root node is always of type Program
. It has one or more child elements under it.
Identity
The simplest filter is .
. It consumes JSON and produces the same output, unchanged.
.
produces the following AST:
Program
|
|
Identity(value: None)
ObjectIdentifierIndex
The Object Identifier Index is meant to return the value for a property. Given the filter .foo
, the implementing program is supposed to return the property foo
's value.
Program
|
|
ObjectIdentifierIndex(value: Some("foo"))
MIT