Skip to main content

Crate cynos_jsonb

Crate cynos_jsonb 

Source
Expand description

Cynos JSONB - JSONB data type implementation for Cynos database.

This crate provides a complete JSONB implementation including:

  • JsonbValue: The core JSON value type with sorted object keys
  • JsonbBinary: Binary encoding/decoding for efficient storage
  • JsonPath: JSONPath query language support
  • JsonbOp: PostgreSQL-compatible JSONB operators
  • GIN index support for efficient querying

§Example

use cynos_jsonb::{JsonbValue, JsonbObject, JsonPath, JsonbBinary};

// Create a JSON object
let mut obj = JsonbObject::new();
obj.insert("name".into(), JsonbValue::String("Alice".into()));
obj.insert("age".into(), JsonbValue::Number(25.0));

let json = JsonbValue::Object(obj);

// Query with JSONPath
let path = JsonPath::parse("$.name").unwrap();
let results = json.query(&path);
assert_eq!(results[0], &JsonbValue::String("Alice".into()));

// Binary encoding
let binary = JsonbBinary::encode(&json);
let decoded = binary.decode();
assert_eq!(json, decoded);

Re-exports§

pub use path::CompareOp;
pub use path::JsonPath;
pub use path::JsonPathPredicate;
pub use path::ParseError;
pub use path::PredicateValue;

Modules§

path
JSONPath module for JSONB queries.

Structs§

JsonbBinary
Binary representation of a JSONB value.
JsonbObject
A JSON object with keys sorted for efficient lookup.

Enums§

JsonbOp
JSONB operations that can be applied to values.
JsonbValue
A JSON value with optimized storage for database operations.