1.5.0 • Published 3 years ago

jsonapi-util v1.5.0

Weekly downloads
14
License
MIT
Repository
github
Last release
3 years ago

jsonapi-util codecov npm version CircleCI

Util functions for working with jsonapi 1.0 structures

Install

You can install using Node Package Manager (npm):

npm install jsonapi-util

Usage

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"
      }
    }
  ]
}
*/

API

Methods

parse(obj)

Parse a jsonapi document object to resolves includes and returns a tree structured object.

isDocument(obj)

Verify if a object is a valid JSON API document

isResoucre(obj)

Verify if a object is a valid JSON API resource object

1.5.0

3 years ago

1.4.0

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.3.2

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago