hiltontj / serde_json_path

Query serde_json Values with JSONPath
https://serdejsonpath.live/
MIT License
50 stars 3 forks source link

How to query a path with the "$" sign in the field name #89

Closed je888 closed 5 months ago

je888 commented 5 months ago

For example, a data:

let value = json!([
    {"name": "n1", "$age": 100},
    {"name": "n2", "$age": 200}
]);

How to query all "$age"?

je888 commented 5 months ago

I've found a solution:

let path = JsonPath::parse(r#"$..['$age']"#).unwrap();

Thank you for the library!

hiltontj commented 5 months ago

Thank you @je888 - glad you figured it out 🙂