serde_hjson/
lib.rs

1//! # What is Hjson?
2//!
3//! A configuration file format for humans. Relaxed syntax, fewer mistakes, more comments.
4//! See <https://hjson.github.io>
5//!
6//! Data types that can be encoded are JavaScript types (see the `serde_hjson:Value` enum for more
7//! details):
8//!
9//! * `Boolean`: equivalent to rust's `bool`
10//! * `I64`: equivalent to rust's `i64`
11//! * `U64`: equivalent to rust's `u64`
12//! * `F64`: equivalent to rust's `f64`
13//! * `String`: equivalent to rust's `String`
14//! * `Array`: equivalent to rust's `Vec<T>`, but also allowing objects of different types in the
15//!    same array
16//! * `Object`: equivalent to rust's `serde_hjson::Map<String, serde_hjson::Value>`
17//! * `Null`
18//!
19//!
20//! # Examples of use
21//!
22//! ## Parsing a `str` to `Value` and reading the result
23//!
24//! ```rust
25//! use serde_hjson::Value;
26//!
27//! fn main() {
28//!     let data: Value = serde_hjson::from_str("{foo: 13, bar: \"baz\"}").unwrap();
29//!     println!("data: {:?}", data);
30//!     println!("object? {}", data.is_object());
31//!
32//!     let obj = data.as_object().unwrap();
33//!     let foo = obj.get("foo").unwrap();
34//!
35//!     println!("array? {:?}", foo.as_array());
36//!     // array? None
37//!     println!("u64? {:?}", foo.as_u64());
38//!     // u64? Some(13u64)
39//!
40//!     for (key, value) in obj.iter() {
41//!         println!("{}: {}", key, match *value {
42//!             Value::U64(v) => format!("{} (u64)", v),
43//!             Value::String(ref v) => format!("{} (string)", v),
44//!             _ => unreachable!(),
45//!         });
46//!     }
47//!     // bar: baz (string)
48//!     // foo: 13 (u64)
49//! }
50//! ```
51
52#![deny(missing_docs)]
53#![allow(clippy::match_like_matches_macro)]
54#![allow(clippy::needless_doctest_main)]
55
56#[macro_use]
57extern crate lazy_static;
58
59extern crate core;
60#[cfg(feature = "preserve_order")]
61extern crate linked_hash_map;
62extern crate num_traits;
63extern crate regex;
64extern crate serde;
65
66pub use self::de::{
67    from_iter, from_reader, from_slice, from_str, Deserializer, StreamDeserializer,
68};
69pub use self::error::{Error, ErrorCode, Result};
70pub use self::ser::{to_string, to_vec, to_writer, Serializer};
71pub use self::value::{from_value, to_value, Map, Value};
72
73pub mod builder;
74pub mod de;
75pub mod error;
76pub mod ser;
77mod util;
78pub mod value;