pub fn jsonb<E: BinaryOrNullableBinary + MaybeNullableValue<Jsonb>, e>(
e: e,
) -> jsonb<E, e>where
e: AsExpression<E>,
Available on crate feature
sqlite
only.Expand description
The jsonb(X) function returns the binary JSONB representation of the JSON provided as argument X.
This function requires at least SQLite 3.45 or newer
ยงExample
let result = diesel::select(jsonb::<Binary, _>(br#"{"a": "b", "c": 1}"#))
.get_result::<Value>(connection)?;
assert_eq!(json!({"a": "b", "c": 1}), result);
let result = diesel::select(jsonb::<Binary, _>(br#"{"this":"is","a":["test"]}"#))
.get_result::<Value>(connection)?;
assert_eq!(json!({"this":"is","a":["test"]}), result);
let result = diesel::select(jsonb::<Nullable<Binary>, _>(None::<Vec<u8>>))
.get_result::<Option<Value>>(connection)?;
assert!(result.is_none());