Is a JSON data expression lexer, parser, cli and library.
How to install CLI
~ cargo install ksql
Expressions
Expressions support most mathematical and string expressions see here for details of the lexer support and rules.
Usage
use ksql::parser::{Parser, Value};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>>{
let src = r#"{"name":"MyCompany", "properties":{"employees": 50}"#;
let expression = ".properties.employees > 20";
let ex = Parser::parse(expression.as_bytes())?;
let result = ex.calculate(src)?;
assert_eq!(Value::Bool(true), result);
Ok(())
}
License