Expand description
JSON serialization and deserialization for the Forma framework.
§Quick start
use forma_json::{to_string, from_str};
use forma_core::ser::Serialize;
use forma_core::de::Deserialize;
// Serialize
let v: Vec<i32> = vec![1, 2, 3];
let json = to_string(&v).unwrap();
assert_eq!(json, "[1,2,3]");
// Deserialize
let v: Vec<i32> = from_str(&json).unwrap();
assert_eq!(v, [1, 2, 3]);Re-exports§
Modules§
Functions§
- from_
reader - Deserialize a value from a JSON
io::Readsource. - from_
slice - Deserialize a value from JSON bytes.
- from_
slice_ lenient - Deserialize a value from JSON bytes with lenient type coercion.
- from_
str - Deserialize a value from a JSON string.
- from_
str_ lenient - Deserialize a value from a JSON string with lenient type coercion.
- to_
string - Serialize a value to a JSON string.
- to_
string_ pretty - Serialize a value to a pretty-printed JSON string with 2-space indentation.
- to_vec
- Serialize a value to a JSON byte vector.
- to_
writer - Serialize a value as JSON into an
io::Write. - to_
writer_ pretty - Serialize a value as pretty-printed JSON into an
io::Writewith 2-space indentation.