Util functions for working with jsonapi 1.0 structures
You can install using Node Package Manager (npm
):
npm install jsonapi-util
var jsonapi = require('jsonapi-util')
var result = jsonapi.parse({
data: [
{
type: "article",
id: "man-of-steel",
relationships: {
author: {
data: {
type: "person",
id: "superman"
}
}
}
}
],
included: [
{
type: "person",
id: "superman",
attributes: {
alias: 'Clark Kent',
name: 'Kal-El'
}
}
]
});
console.log(result);
/* returns :>
{
data:[
{
type: "article",
id: "man-of-steel",
author: {
type: "person",
id: "superman",
alias: "Clark Kent",
name: "Kal-El"
}
}
]
}
*/
Parse a jsonapi document object to resolves includes and returns a tree structured object.
Verify if a object is a valid JSON API document
Verify if a object is a valid JSON API resource object