pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
Str(String),
Array(Vec<Value>),
Object(Vec<(String, Value)>),
}Variants§
Implementations§
Source§impl Value
impl Value
Sourcepub fn order(&self, other: &Value) -> Ordering
pub fn order(&self, other: &Value) -> Ordering
Total order across types (jq’s ordering: null < bool < number < string < array < object).
Sourcepub fn value_eq(&self, other: &Value) -> bool
pub fn value_eq(&self, other: &Value) -> bool
Structural equality consistent with Value::order.
Sourcepub fn to_raw_string(&self) -> String
pub fn to_raw_string(&self) -> String
Render as a raw scalar for query output (no surrounding quotes on strings). Composite values are rendered as JSON.
Sourcepub fn to_json5(&self) -> String
pub fn to_json5(&self) -> String
Render as compact JSON in the JSON5 spelling: non-finite floats keep
their Infinity / -Infinity / NaN literals instead of degrading to
null. This is what the JSONC/JSON5-family emitters use, so converting
or querying a JSON5 source with a non-finite number preserves it; strict
JSON must use Value::to_json (which, like JSON.stringify, encodes
one as null).
Trait Implementations§
Source§impl<T: Into<Value>> From<Option<T>> for Value
None is JSON’s null; Some(v) is whatever v converts to.
impl<T: Into<Value>> From<Option<T>> for Value
None is JSON’s null; Some(v) is whatever v converts to.
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more