1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Deserializes JSON values while rejecting duplicate object keys.
use Deserialize;
use Deserializer;
use DeserializeSeed;
use Value;
pub use DuplicateKeyRejectingJsonValueSeed;
/// 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);
/// # Ok::<(), serde_json::Error>(())
/// ```
;