pub enum Value {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec<Value>),
Object(Vec<Entry>),
}Expand description
A parsed TJSON value. Mirrors the JSON type system with the same six variants.
Numbers are stored as Number values, which preserve the exact string representation.
Objects are stored as an ordered Vec of key-value pairs, which allows duplicate keys
at the data structure level (though JSON and TJSON parsers typically deduplicate them).
Variants§
Null
JSON null.
Bool(bool)
JSON boolean.
Number(Number)
JSON number.
String(String)
JSON string.
Array(Vec<Value>)
JSON array.
Object(Vec<Entry>)
JSON object, as an ordered list of key-value pairs.
Implementations§
Source§impl Value
impl Value
Sourcepub fn to_tjson_with(&self, options: RenderOptions) -> String
pub fn to_tjson_with(&self, options: RenderOptions) -> String
Render this value as a TJSON string using the given options.
use tjson::{Value, RenderOptions};
let v: Value = " name: Alice age:30".parse().unwrap();
let s = v.to_tjson_with(RenderOptions::canonical());
assert_eq!(s, " name: Alice\n age:30");Trait Implementations§
Source§impl FromStr for Value
let v: tjson::Value = " name: Alice".parse().unwrap();
assert!(matches!(v, tjson::Value::Object(_)));
impl FromStr for Value
let v: tjson::Value = " name: Alice".parse().unwrap();
assert!(matches!(v, tjson::Value::Object(_)));impl Eq for Value
impl StructuralPartialEq for Value
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.