Struct json5format::ParsedDocument
source · pub struct ParsedDocument {
pub content: Array,
/* private fields */
}
Expand description
Represents the parsed state of a given JSON5 document.
Fields§
§content: Array
The parsed document model represented as an array of zero or more objects to format.
Implementations§
source§impl ParsedDocument
impl ParsedDocument
sourcepub fn from_str(buffer: &str, filename: Option<String>) -> Result<Self, Error>
pub fn from_str(buffer: &str, filename: Option<String>) -> Result<Self, Error>
Parses the JSON5 document represented by buffer
, and returns a parsed representation of
the document that can be formatted by
Json5Format::to_utf8().
If a filename is also provided, any parsing errors will include the filename with the line number and column where the error was encountered.
sourcepub fn from_str_with_nesting_limit(
buffer: &str,
filename: Option<String>,
nesting_limit: usize,
) -> Result<Self, Error>
pub fn from_str_with_nesting_limit( buffer: &str, filename: Option<String>, nesting_limit: usize, ) -> Result<Self, Error>
Like from_str()
but also overrides the default nesting limit, used to
catch deeply nested JSON5 documents before overflowing the program
stack.
sourcepub fn from_string(
buffer: String,
filename: Option<String>,
) -> Result<Self, Error>
pub fn from_string( buffer: String, filename: Option<String>, ) -> Result<Self, Error>
Parses the JSON5 document represented by buffer
, and returns a parsed representation of
the document that can be formatted by
Json5Format::to_utf8().
The returned ParsedDocument
object retains ownership of the input buffer, which can be
useful in situations where borrowing the buffer (via
from_str() requires burdensome workarounds.
If a filename is also provided, any parsing errors will include the filename with the line number and column where the error was encountered.
sourcepub fn filename(&self) -> &Option<String>
pub fn filename(&self) -> &Option<String>
Returns the filename, if provided when the object was created.
sourcepub fn input_buffer(&self) -> &Option<String>
pub fn input_buffer(&self) -> &Option<String>
Borrows the input buffer owned by this object, if provided by calling from_string().