pub struct RawJsonOwned { /* private fields */ }Expand description
Owned version of RawJson.
Implementations§
Source§impl RawJsonOwned
impl RawJsonOwned
Sourcepub fn parse<T>(text: T) -> Result<Self, JsonParseError>
pub fn parse<T>(text: T) -> Result<Self, JsonParseError>
Parses a JSON string into a RawJsonOwned instance.
This validates the JSON syntax without converting values to Rust types.
Unlike RawJson::parse, this creates an owned version that doesn’t
borrow from the input string.
§Example
let text = r#"{"name": "John", "age": 30}"#;
let json = RawJsonOwned::parse(text)?;Sourcepub fn value(&self) -> RawJsonValue<'_, '_>
pub fn value(&self) -> RawJsonValue<'_, '_>
Returns the top-level value of the JSON.
This value can be used as an entry point to traverse the entire JSON structure and convert it to Rust types.
§Example
let text = r#"{"name": "John", "age": 30}"#;
let json = RawJsonOwned::parse(text).unwrap();
let value = json.value();Sourcepub fn get_value_by_position(
&self,
position: usize,
) -> Option<RawJsonValue<'_, '_>>
pub fn get_value_by_position( &self, position: usize, ) -> Option<RawJsonValue<'_, '_>>
Finds the JSON value at the specified byte position in the original text.
This method traverses the JSON structure to find the most specific value
that contains the given position.
It returns None if the position is outside the bounds of the JSON text.
This method is useful for retrieving the context
where a JsonParseError::InvalidValue error occurred.
§Example
let json = RawJsonOwned::parse(r#"{"name": "John", "age": 30}"#)?;
// Position at "name" key
let name_value = json.get_value_by_position(2).expect("infallible");
assert_eq!(name_value.as_raw_str(), r#""name""#);
// Position at number value
let age_value = json.get_value_by_position(25).expect("infallible");
assert_eq!(age_value.as_raw_str(), "30");Trait Implementations§
Source§impl Clone for RawJsonOwned
impl Clone for RawJsonOwned
Source§fn clone(&self) -> RawJsonOwned
fn clone(&self) -> RawJsonOwned
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RawJsonOwned
impl Debug for RawJsonOwned
Source§impl Display for RawJsonOwned
impl Display for RawJsonOwned
Source§impl DisplayJson for RawJsonOwned
impl DisplayJson for RawJsonOwned
Source§impl FromStr for RawJsonOwned
impl FromStr for RawJsonOwned
Source§impl Hash for RawJsonOwned
impl Hash for RawJsonOwned
Source§impl Ord for RawJsonOwned
impl Ord for RawJsonOwned
Source§impl PartialEq for RawJsonOwned
impl PartialEq for RawJsonOwned
Source§impl PartialOrd for RawJsonOwned
impl PartialOrd for RawJsonOwned
Source§impl<'text, 'raw> TryFrom<RawJsonValue<'text, 'raw>> for RawJsonOwned
impl<'text, 'raw> TryFrom<RawJsonValue<'text, 'raw>> for RawJsonOwned
Source§type Error = JsonParseError
type Error = JsonParseError
The type returned in the event of a conversion error.
impl Eq for RawJsonOwned
Auto Trait Implementations§
impl Freeze for RawJsonOwned
impl RefUnwindSafe for RawJsonOwned
impl Send for RawJsonOwned
impl Sync for RawJsonOwned
impl Unpin for RawJsonOwned
impl UnwindSafe for RawJsonOwned
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