jsonapi is the Rust library for serialization, deserialization and working with JSON-API data
This is an implementation of the JSON-API v1 specification at jsonapi.org - http://jsonapi.org/.
Add this crate to your
Or use the master branch directly from github,
Examples of most serialization and deserialization cases can be found in the tests/ - https://github.com/michiel/jsonapi-rust/tree/master/tests directory or the documentation - https://docs.rs/jsonapi.
Basic Usage with Macro
jsonapi_model! macro a struct can be converted into a
Resource. It is required that the struct have an id property whose type is String. The second argument in the
jsonapi_model! marco defines the type member as required by the JSON:API specification
extern crate serde_derive;
Deserializing a JSON:API Document
JSON:API document using serde by explicitly declaring the variable type in Result
let serialized = r#"
Or parse the String directly using the
Resource::from_str trait implementation
let data = Resource::from_str(&serialized);
JsonApiDocument implements PartialEq which allows two documents to be compared for equality. If two documents possess the same contents the ordering of the attributes and fields within the
JSON:API document are irrelevant and their equality will be true.