Trait json_syntax::TryFromJson
source · pub trait TryFromJson: Sized {
type Error;
// Required method
fn try_from_json_at(
value: &Value,
code_map: &CodeMap,
offset: usize,
) -> Result<Self, Self::Error>;
// Provided method
fn try_from_json(
value: &Value,
code_map: &CodeMap,
) -> Result<Self, Self::Error> { ... }
}
Expand description
Conversion from JSON syntax, with code mapping info.
This trait is very similar to TryFrom<Value>
but also passes code
code mapping info to the conversion function.
Required Associated Types§
Required Methods§
sourcefn try_from_json_at(
value: &Value,
code_map: &CodeMap,
offset: usize,
) -> Result<Self, Self::Error>
fn try_from_json_at( value: &Value, code_map: &CodeMap, offset: usize, ) -> Result<Self, Self::Error>
Tries to convert the given JSON value into Self
, using the given
code_map
and the offset of value
in the code map.
Note to implementors: use the JsonArray::iter_mapped
and
Object::iter_mapped
methods to visit arrays and objects while
keeping track of the code map offset of each visited item.
Provided Methods§
Object Safety§
This trait is not object safe.