JSPM

  • Created
  • Published
  • Downloads 51162
  • Score
    100M100P100Q147528F
  • License MIT

A Node.js framework agnostic library for serializing your data to JSON API

Package Exports

  • jsonapi-serializer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jsonapi-serializer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSON API Serializer

Build Status

A Node.js framework agnostic library for serializing your data to JSON API (1.0 compliant).

Installation

$ npm install jsonapi-serializer

Usage

Here's an example of serializing a User resource to JSON API.

  var JSONAPISerializer = require('jsonapi-serializer');

  new JSONAPISerializer('users', data, {
    apiEndpoint: 'http://localhost:3000/api',
    attributes: ['firstName', 'lastName', 'address', 'books'],
    address: {
      ref: '_id',
      attributes: ['addressLine1', 'addressLine2', 'zipCode', 'country']
    },
    books: {
      ref: '_id',
      attributes: ['title', 'ISBN']
    }
  }).then(function (users) {
    // `users` here is JSON API compliant.
  });

License

MIT