1.5.0 • Published 2 years ago

jsonapi-util v1.5.0

Weekly downloads
14
License
MIT
Repository
github
Last release
2 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

2 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.3.2

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago