sqlite_value_to_json

Function sqlite_value_to_json 

Source
pub fn sqlite_value_to_json(value: &Value) -> Result<Value>
Expand description

Convert a single SQLite value to JSON

Maps SQLite types to JSON types:

  • INTEGER → number (i64)
  • REAL → number (f64)
  • TEXT → string (UTF-8)
  • BLOB → object with base64-encoded data
  • NULL → null

§Arguments

  • value - SQLite value from rusqlite

§Returns

JSON value suitable for JSONB storage

§Examples

let sqlite_int = Value::Integer(42);
let json = sqlite_value_to_json(&sqlite_int).unwrap();
assert_eq!(json, serde_json::json!(42));