Crates.io | sql-json-path |
lib.rs | sql-json-path |
version | 0.1.0 |
source | src |
created_at | 2023-11-29 17:01:47.207016 |
updated_at | 2023-11-29 17:01:47.207016 |
description | SQL/JSON Path implementation in Rust. |
homepage | |
repository | https://github.com/risingwavelabs/sql-json-path |
max_upload_size | |
id | 1053339 |
size | 237,324 |
SQL/JSON Path implementation in Rust.
serde_json
, simd-json
and jsonbb
. Custom JSON types are also supported.use serde_json::{json, Value};
use sql_json_path::JsonPath;
let json = json!({"a": 1});
let path = JsonPath::new("$.a").unwrap();
let nodes = path.query(&json).unwrap();
assert_eq!(nodes.len(), 1);
assert_eq!(nodes[0].to_string(), "1");
See PostgreSQL documentation for more details.
strict
and lax
mode$
: Root object@
: Current object[index]
: An array element by index
[start to end]
: An array slice[index1, index2, ...]
: Multiple array elements[last]
: The last array element.name
: An object member by name[*]
: Any array element.*
: Any object member.**
: Any descendant object member (Postgres extension)?(predicate)
: Filter expression
==
, !=
/ <>
, <
, <=
, >
, >=
: Comparison&&
, ||
, !
: Logical operatorsis unknown
: Check if the value is unknownlike_regex
: Check if the string matches the regular expressionstarts with
: Check if the string starts with the given prefixexists(expr)
: Check if the expression matches any value+
: Addition / Unary plus-
: Subtraction / Negation*
: Multiplication/
: Division%
: Modulo.type()
.size()
.double()
.ceiling()
.floor()
.abs()
.datetime()
.datetime(template)
.keyvalue()
This crate is tested against PostgreSQL regression tests: cargo test --test pg_jsonb_jsonpath
. 325 out of 430 tests are passed. 96 tests are skipped because they have unsupported features. 9 tests are failed because of incorrect implementation.
Licensed under Apache License, Version 2.0.