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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Parse [Hjson](https://hjson.github.io/) compatible with deser.
//!
//! Hjson is JSON for humans, a format for configuration files:
//!
//! * `#`, `//` and `/* */` comments,
//! * commas between values are optional, commas after the last element of
//! sequences and maps are allowed,
//! * map keys without quotes (`name: api`), they end at whitespace and
//! the punctuators `{}[],:`,
//! * strings without quotes, which end at the end of the line (`note:
//! runs until the end, #, and // too`),
//! * multiline strings in triple single quotes (`'''`), the indentation up
//! to the column of the opening quotes is removed,
//! * strings in single quotes,
//! * the braces of a map at the root can be omitted.
//!
//! Numbers, `true`, `false` and `null` without quotes are values only if
//! nothing but whitespace, a comma, the end of a container or a comment
//! follows them on the line: `5 # minutes` is the number `5`, `5 minutes`
//! is a string. Their type is inferred from their text, so they are
//! passed on as [`Implicit`](deser_core::Implicit) values: an `u16`
//! receives `8080` as number, a `String` as `"8080"`.
//!
//! Otherwise this works like [`deser-json`](https://docs.rs/deser-json):
//! strings and keys without escape sequences are borrowed from the input and
//! the positions of errors and values refer to the input. In [JSON
//! Lines](Trailing::Newline) every line break ends a value. The parser passes the [Hjson test
//! suite](https://github.com/hjson/hjson/tree/master/testCases).
//!
//! ```rust
//! #[derive(deser::Deserialize)]
//! struct Config<'a> {
//! name: &'a str,
//! version: String,
//! ports: Vec<u16>,
//! motd: String,
//! }
//!
//! let config: Config = deser_hj::from_str(r#"
//! ## the name of the service
//! name: api
//! version: 2
//! ports: [80, 443]
//! motd:
//! '''
//! Welcome!
//! Have a nice day.
//! '''
//! "#).unwrap();
//! assert_eq!(config.name, "api");
//! assert_eq!(config.version, "2");
//! assert_eq!(config.ports, [80, 443]);
//! assert_eq!(config.motd, "Welcome!\nHave a nice day.");
//! ```
//!
//! JSON is valid Hjson, so values are serialized as JSON (with the same
//! serializer as `deser-json`).
//!
//! # Features
//!
//! * `io` (enabled by default): reading and writing streams of the
//! standard library (with `DeserializerConfig::reader`). Requires
//! `std`.
//! * `speedups` (enabled by default): faster UTF-8 validation.
//! * `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)).
extern crate alloc;
// These are generated from `deser-template-json`.
pub use ;
pub use to_writer;
pub use ;
pub use StreamDeserializer;
pub use from_reader;
pub use Trailing;