pub struct JsonDecodeError {
pub kind: JsonDecodeErrorKind,
pub message: String,
pub expected_top_level: Option<JsonTopLevelKind>,
pub actual_top_level: Option<JsonTopLevelKind>,
pub line: Option<usize>,
pub column: Option<usize>,
}Expand description
Error returned when lenient JSON decoding fails.
This value captures both a stable category in JsonDecodeErrorKind and
human-readable context that can be logged or surfaced to the caller.
Fields§
§kind: JsonDecodeErrorKindIdentifies the stable category of this decoding failure.
Callers should match on this field when they need programmatic handling that is independent from localized or parser-specific text.
message: StringStores a human-readable summary of the decoding failure.
The message is intended for diagnostics and normally includes the relevant parsing or deserialization context.
expected_top_level: Option<JsonTopLevelKind>Stores the top-level JSON kind required by the caller, when applicable.
This field is only populated for errors raised by constrained decoding
methods such as decode_object() and decode_array().
actual_top_level: Option<JsonTopLevelKind>Stores the top-level JSON kind that was actually parsed, when known.
This field is only populated together with expected_top_level for
top-level contract mismatches.
line: Option<usize>Stores the one-based line reported by serde_json, when available.
This field is primarily useful for invalid JSON syntax and deserialization failures that can be mapped back to a parser location.
column: Option<usize>Stores the one-based column reported by serde_json, when available.
Like line, this field is only populated when the lower-level parser
or deserializer reports a concrete source position.
Trait Implementations§
Source§impl Clone for JsonDecodeError
impl Clone for JsonDecodeError
Source§fn clone(&self) -> JsonDecodeError
fn clone(&self) -> JsonDecodeError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JsonDecodeError
impl Debug for JsonDecodeError
Source§impl Display for JsonDecodeError
impl Display for JsonDecodeError
Source§impl Error for JsonDecodeError
impl Error for JsonDecodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()