Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

normalize-json-api

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-json-api

Normalizes JSON API responses for Redux and Flux applications

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

normalize-json-api build status npm version

Normalizes JSON API responses according to a schema for Flux and Redux apps. More on JSON API. Thanks to paularmstrong and Dan Abramov for building normalizr where the original idea of this library came from :)

Installation

npm install --save normalize-json-api

The Problem

  • You have a JSON API sideloaded objects ;
  • You want to port your app to Flux or Redux;
  • You noticed it's hard for Stores (or Reducers) to consume data from nested API responses.

normalize-json-api takes JSON API and

For example,

{
  data: {
    id: 1,
    type: 'articles',
    attributes: {
      title: 'Shoes',
      'is-favorite': false,
    },
    relationships: {
      author: {
        data: {
          type: 'users',
          id: 9,
        },
      },
    },
  },
  included: [
    {
      type: 'users',
      id: 9,
      attributes: {
        'first-name': 'Marie',
        'last-name': 'Brizard',
        twitter: 'mb',
      },
    },
  ],
}

can be normalized to

{
  results: {
    articles: [1],
    users: [9],
  },
  entities: {
    articles: {
      1: {
        id: 1,
        type: 'articles',
        title: 'Shoes',
        isFavorite: false,
        author: 9,
      },
    },
    users: {
      9: {
        id: 9,
        type: 'users',
        firstName: 'Marie',
        lastName: 'Brizard',
        twitter: 'mb',
      },
    },
  },
}

Features

TODO

Usage

TODO

Credits

normalize-json-api was inspired heavily by normalizr

Keywords

FAQs

Package last updated on 10 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc