json-api-deserialize
Massively simplifies the process of working with JSON:API data on the frontend.
- Nests included objects on resources 🕸
- Normalizes data structures 🏗
- Converts all object keys to camelCased values 🐫
- Written in TypeScript 🎉
- Compliant with JSON:API v1.0 Spec 📜
- Rigorously tested 🔬
Raw
Deserialized
data: id: '1' name: 'Mercer Island Book Store' createdAt: '2019-06-30T22:33:41+0000' updatedAt: '2019-06-30T22:33:41+0000' owner: id: '2' fullName: 'John Doe' createdAt: '2019-06-30T22:33:41+0000' updatedAt: '2019-06-30T22:33:41+0000' address: id: '3' street: '123 Test Ave' type: 'commercial' zipCode: '12345' createdAt: '2019-06-30T22:33:41+0000' updatedAt: '2019-06-30T22:33:41+0000' driveway: id: '4' type: 'parking_lot' createdAt: '2019-06-30T22:33:41+000' updatedAt: '2019-06-30T22:33:41+0000' deserialized: true
Pair with Axios interceptors for a seamless experience.
; axiosinterceptorsresponse;
const fetchBookstore = async { const data: store = await ; console; // 👉 John Doe};
Install
yarn add json-api-deserialize
npm i json-api-deserialize
API
Deserialize
deserializerawJsonApiDocument, options?): deserializedResponseObject | rawJsonApiDocument;
Options:
- Normalize (boolean, default: true)
- Flattens the deserialized response object to spread
attributes
andrelationships
properties to the same level asid
- Converts all object keys to camelCase variants
- Flattens the deserialized response object to spread
deserialize
returns a deserialized response object and falls back to the raw response object if an exception is caught.