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
//! A JSON (compact) serde serializer for [`ser-write`](`ser_write`) and a JSON deserializer for convenience.
/*!
[`Serializer`] types:
| Serde type -> | JSON type
|-------------------|--------------------
| `()` | `null`
| `Unit` struct | `null`
| `bool` | `boolean`
| `NewType(T)` | `T` -> `JSON`
| `None` | `null`
| `Some(T)` | `T` -> `JSON`
| `u8`-`u64` | `number`
| `i8`-`i64` | `number`
| `f23`,`f64` | `number`
| `str` | `string`
| `bytes` | (configurable)
| `array`, `tuple` | `array`
| `seq`-like | `array`
| `map`-like | `object`
| `struct` | `object`
| `unit variant` | `string`
| `newtype variant` | `{"Name":T -> JSON}`
| `tuple variant` | `{"Name": array}`
| `struct variant` | `{"Name": object}`
[`Deserializer`] supports self-describing formats (`deserialize_any`).
[`Deserializer`] deserializes structs from both JSON objects or arrays.
[`Deserializer`] types:
| JSON type -> | Serde type (depending on context)
|-------------------|----------------------------------------
| `null` | `unit`,`none`,`NaN`
| `boolean` | `bool`
| `number` | `f64`,`f32`,`u8`-`u64`,`i8`-`i64`
| `string` | `str`,`bytes` (configurable),`enum variant`
| `array` | `array`,`tuple`,`tuple struct`,`typle variant`,`seq-like`,`struct`
| `object` | `enum variant`,`struct variant`,`map-like`,`struct`
| `T` | `NewType(JSON -> T)`, `Some(JSON -> T)`
[`Serializer`]: ser::Serializer
[`Deserializer`]: de::Deserializer
*/
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(feature = "std")]
extern crate std;
#[cfg(all(feature = "alloc",not(feature = "std")))]
extern crate alloc;
pub mod base64;
pub mod ser;
pub mod de;
pub use ser_write;
pub use ser_write::SerWrite;
#[cfg(any(feature = "std", feature = "alloc"))]
pub use ser::{
to_string,
to_string_hex_bytes,
to_string_base64_bytes,
to_string_pass_bytes
};
pub use ser::{
to_writer_with_encoder,
to_writer,
to_writer_hex_bytes,
to_writer_base64_bytes,
to_writer_pass_bytes
};
pub use de::{
from_mut_slice_with_decoder,
from_mut_slice,
from_mut_slice_hex_bytes,
from_mut_slice_base64_bytes
};