Value

Type Alias Value 

Source
pub type Value = Spanned<Value>;
Expand description

Owned, arbitrary json value + span information

Aliased Type§

pub struct Value { /* private fields */ }

Implementations§

Source§

impl Value

Various conversion methods:

  • as_span_[type]() returns borrowing Options of some sort.
  • into_span_[type]() returns Ok(type) or Err(original).

See also on super::Value as provided by Deref implementation:

  • is_[type]() returns bools with obvious meanings.
  • as_[type]() for borrowing Options without span info.
  • into_[type]() for Ok(type) without span info, or Err(original).
Source

pub fn as_span_null(&self) -> Option<Null>

Some(span + ()) if self is null`

Source

pub fn as_span_bool(&self) -> Option<Bool>

Some(span + inner) if self is true or false

Source

pub fn as_span_number(&self) -> Option<Num<'_>>

Some(span + &inner) if self is a number like 123

Source

pub fn as_span_string(&self) -> Option<Str<'_>>

Some(span + &inner) if self is a string like "asdf"

Source

pub fn as_span_array(&self) -> Option<Span<'_>>

Some(span + &inner) if self is an array like [1, 2, 3]

Source

pub fn as_span_object(&self) -> Option<Obj<'_>>

Some(span + &inner) if self is an object like {"a": 1, "b": 2}

Source

pub fn into_span_null(self) -> Result<Null, Self>

Ok(span + ()) if self is null, otherwise Err(self)

Source

pub fn into_span_bool(self) -> Result<Bool, Self>

Ok(span + inner) if self is true or false, otherwise Err(self)

Source

pub fn into_span_number(self) -> Result<Number, Self>

Ok(span + inner) if self is a number like 123, otherwise Err(self)

Source

pub fn into_span_string(self) -> Result<String, Self>

Ok(span + inner) if self is a string like "asdf", otherwise Err(self)

Source

pub fn into_span_array(self) -> Result<Array, Self>

Ok(span + inner) if self is an array like [1, 2, 3], otherwise Err(self)

Source

pub fn into_span_object(self) -> Result<Object, Self>

Ok(span + inner) if self is an object like {"a": 1, "b": 2}, otherwise Err(self)

Source

pub fn pointer(&self, path: &str) -> Option<&Value>

Lookup a value by JSON Pointer (RFC 6901)

Source

pub fn pointer_mut(&mut self, path: &str) -> Option<&mut Value>

Lookup a value by JSON Pointer (RFC 6901)