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
//! Parse [JSON5](https://json5.org/) compatible with deser.
//!
//! JSON5 extends JSON with syntax from ECMAScript 5.1:
//!
//! * `//` and `/* */` comments,
//! * commas after the last element of sequences and maps,
//! * map keys which are ECMAScript identifiers (`{name: "api"}`, with
//! Unicode letters and `\u` escapes),
//! * strings in single quotes, escaped line breaks within strings and the
//! escapes `\'`, `\v`, `\0` and `\xFF`,
//! * hexadecimal numbers (those that do not fit into 64 bits are 128 bit
//! integers and floats beyond that), numbers with a leading `+` or a
//! leading or trailing decimal point, `Infinity` and `NaN`,
//! * more whitespace characters.
//!
//! Otherwise this works like [`deser-json`](https://docs.rs/deser-json):
//! strings and identifiers without escape sequences are borrowed from the
//! input and the positions of errors and values refer to the input. In
//! [JSON Lines](Trailing::Newline) only line breaks outside of comments and
//! strings end a value. The parser passes the [JSON5 test
//! suite](https://github.com/json5/json5-tests).
//!
//! ```rust
//! #[derive(deser::Deserialize)]
//! struct Config<'a> {
//! name: &'a str,
//! ports: Vec<u16>,
//! timeout: f64,
//! }
//!
//! let config: Config = deser_json5::from_str(r#"{
//! // the name of the service
//! name: 'api',
//! ports: [0x50, 443,],
//! timeout: .5,
//! }"#).unwrap();
//! assert_eq!(config.name, "api");
//! assert_eq!(config.ports, [80, 443]);
//! assert_eq!(config.timeout, 0.5);
//! ```
//!
//! JSON is valid JSON5, so values are serialized as JSON with the
//! serializer of `deser-json` (which is re-exported).
//!
//! # Features
//!
//! * `io` (enabled by default): reading and writing streams of the
//! standard library (with `DeserializerConfig::reader`). Requires
//! `std`.
//! * `speedups`: faster UTF-8 validation. Implies `zmij`.
//! * `std` (enabled by default): uses the standard library. Without it
//! this crate only needs `alloc` (see [`no_std`](https://docs.rs/deser/latest/deser/#no_std)).
//! * `zmij` (enabled by default): formats floats with
//! [`zmij`](https://docs.rs/zmij) when serializing (see `deser-json`).
extern crate alloc;
// These are generated from `deser-template-json`.
pub use ;
pub use StreamDeserializer;
pub use from_reader;
pub use to_writer;
pub use ;