# forma_json
JSON serializer and deserializer for the
[forma](https://crates.io/crates/forma) serialization framework.
**Most users should use `forma` with the `json` feature instead of depending on
this crate directly:**
```toml
[dependencies]
forma = { version = "0.1", features = ["derive", "json"] }
```
## Quick Example
```rust
use forma_json::{to_string, to_string_pretty, from_str, Value};
// Serialize to JSON
let json = to_string(&value).unwrap();
let pretty = to_string_pretty(&value).unwrap();
// Deserialize from JSON
let v: MyStruct = from_str(&json).unwrap();
// Dynamic Value type
let val: Value = from_str(r#"{"key": [1, 2, 3]}"#).unwrap();
assert_eq!(val["key"][0].as_u64(), Some(1));
```
## API
- **`to_string`** / **`to_string_pretty`** -- serialize to a JSON string.
- **`to_vec`** / **`to_writer`** -- serialize to bytes or an `io::Write`.
- **`from_str`** / **`from_slice`** -- deserialize from a string or byte slice.
- **`Value`** -- dynamic JSON type with `Index` support for convenient access.
- **`to_value`** / **`from_value`** -- convert between typed values and `Value`.
## Lenient Mode
The deserializer accepts standard JSON. Lenient extensions (trailing commas,
comments) may be added in a future release behind a feature flag.
## License
Licensed under either of Apache License, Version 2.0 or MIT License at your
option.