Skip to main content

Crate forma_json

Crate forma_json 

Source
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§

pub use error::Error;
pub use value::Value;

Modules§

de
error
ser
value

Functions§

from_reader
Deserialize a value from a JSON io::Read source.
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::Write with 2-space indentation.