pub struct DuplicateKeyRejectingJsonValue(/* private fields */);Expand description
A JSON value whose deserialization rejects duplicate object keys.
This wrapper is useful for document formats where accepting the usual
last-key-wins object behavior would make the input ambiguous. Native i64,
u64, and finite f64 events retain their numeric representation. If an
upstream deserializer exposes an arbitrary-precision number as map events,
this wrapper treats those events as an ordinary object because it cannot
determine their provenance. Lexical admission by
crate::decode::JsonDecoder does not change the subsequent Serde event
representation. See doc/number_contract.md in the repository for the
numeric contract.
Use crate::decode::JsonDecoder::decode_unique_str for owned JSON text
decoding that preserves native numbers under feature unification.
§Examples
use qubit_json::value::DuplicateKeyRejectingJsonValue;
let value: DuplicateKeyRejectingJsonValue = serde_json::from_str(r#"{"ok":true}"#)?;
assert_eq!(value.into_inner()["ok"], true);Implementations§
Source§impl DuplicateKeyRejectingJsonValue
impl DuplicateKeyRejectingJsonValue
Sourcepub fn into_inner(self) -> Value
pub fn into_inner(self) -> Value
Returns the validated JSON value.
§Returns
The owned serde_json value constructed during deserialization.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DuplicateKeyRejectingJsonValue
impl<'de> Deserialize<'de> for DuplicateKeyRejectingJsonValue
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserializes JSON recursively while rejecting duplicate object keys.
§Type Parameters
Dis the deserializer that supplies the JSON data and error type.
§Parameters
deserializersupplies the JSON data to validate and materialize.
§Errors
Returns the deserializer’s error if the input is invalid or an object contains a duplicate key.