1#![no_std]
5
6pub use const_json_macros::ConstJson;
14
15mod buffer;
16pub mod parse;
17pub mod ser;
18
19pub use buffer::JsonBuffer;
20pub use parse::{JsonObject, JsonValue, ParseError};
21
22#[cfg(test)]
23extern crate std;
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28 use crate as const_json;
29
30 #[derive(ConstJson)]
31 #[const_json(capacity = 64)]
32 struct Example<'a> {
33 title: &'a str,
34 count: u32,
35 enabled: bool,
36 }
37
38 const fn build_example() -> JsonBuffer<64> {
39 Example {
40 title: "example",
41 count: 42,
42 enabled: true,
43 }
44 .to_json()
45 }
46
47 #[test]
48 fn generates_expected_json() {
49 const BUF: JsonBuffer<64> = build_example();
50 assert_eq!(
51 BUF.as_str(),
52 r#"{"title":"example","count":42,"enabled":true}"#
53 );
54 }
55}