Description
Apparently key can’t be accessed when inside double quotes. We need to add double quotes for keys that have “.” in the key string itself. such that $num.key.1 will make logically different sense.
Steps to Reproduce
- The following code to be included in the main.rs
use jslt::Jslt;
use serde_json::json;
use std::fs;
fn main() -> Result<(), Box <dyn std::error::Error> > {
let jslt: Jslt = r#"
def fun(num)
$num."key.1"
let value = {
"key.1":5,
"key.2":6
}
fun($value)
"#.parse()?;
let input = json!({
"data": [
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10]
]
});
let output = jslt.transform_value(&input)?;
println!("{}",output);
assert_eq!("5",output.to_string());
Ok(())
}
Actual Output
Error: Pest(Error {variant: ParsingError {positives: [EOI, Add, Sub,Mul, Div, Gt, Lt, Gte, Lte,Equal, NotEqual, And, Or],negatives: [] }, location:Pos(30), line_col: Pos((5,1)), path: None, line: "let value = {", continued_line: None, parse_attempts: None })
Expected Output
5
Environment
Nightly Rust Toolchain