json_write/lib.rs
1//! A low-level interface for writing out JSON
2//!
3//! # Example
4//!
5//! ```rust
6//! use json_write::JsonWrite as _;
7//!
8//! # fn main() -> std::fmt::Result {
9//! let mut output = String::new();
10//! output.open_object()?;
11//! output.newline()?;
12//!
13//! output.space()?;
14//! output.space()?;
15//! output.key("key")?;
16//! output.keyval_sep()?;
17//! output.space()?;
18//! output.value("value")?;
19//! output.newline()?;
20//!
21//! output.close_object()?;
22//! output.newline()?;
23//!
24//! assert_eq!(output, r#"{
25//! "key": "value"
26//! }
27//! "#);
28//! # Ok(())
29//! # }
30//! ```
31
32#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
33#![cfg_attr(docsrs, feature(doc_auto_cfg))]
34#![warn(clippy::std_instead_of_core)]
35#![warn(clippy::std_instead_of_alloc)]
36#![warn(clippy::print_stderr)]
37#![warn(clippy::print_stdout)]
38
39#[cfg(feature = "alloc")]
40extern crate alloc;
41
42mod key;
43mod value;
44mod write;
45
46#[cfg(feature = "alloc")]
47pub use key::ToJsonKey;
48pub use key::WriteJsonKey;
49#[cfg(feature = "alloc")]
50pub use value::ToJsonValue;
51pub use value::WriteJsonValue;
52pub use write::JsonWrite;
53
54#[doc = include_str!("../README.md")]
55#[cfg(doctest)]
56pub struct ReadmeDoctests;