serde_json_ext
JSON helpers built on top of serde_json with configurable byte serialization
formats.
Overview
- default array encoding for byte fields
- hexadecimal encoding with optional
0xprefix - base64 and base64 URL-safe encoding
- matching serialization and deserialization helpers
Installation
[]
= "0.1.9"
= { = "1", = ["derive"] }
= "0.11"
Usage
use Serialize;
use ;
let value = Example ;
let config = default.set_bytes_hex.enable_hex_prefix;
let json = to_string.unwrap;
assert_eq!;
API
to_stringto_string_prettyto_vecto_vec_prettyto_writerto_writer_prettyto_valuefrom_strfrom_slicefrom_readerfrom_valueConfigBytesFormat
Notes
- Use
#[serde(with = "serde_bytes")]on byte fields that should use the custom encoding rules. - Serialization and deserialization must use the same
Configvalues. - Hex strings are accepted with or without the
0xprefix during deserialization.
License
MIT