All Projects → paularmstrong → Normalizr

paularmstrong / Normalizr

Licence: mit
Normalizes nested JSON according to a schema

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Normalizr

Php Curl Class
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs
Stars: ✭ 2,903 (-85.99%)
Mutual labels:  api, json
Laravel5 Jsonapi
Laravel 5 JSON API Transformer Package
Stars: ✭ 313 (-98.49%)
Mutual labels:  api, json
Restful Doom
HTTP+JSON API hosted inside the 1993 DOOM engine!
Stars: ✭ 263 (-98.73%)
Mutual labels:  api, json
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (-98.78%)
Mutual labels:  api, json
Newton Api
➗ A really micro micro-service for advanced math.
Stars: ✭ 358 (-98.27%)
Mutual labels:  api, json
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+156.03%)
Mutual labels:  api, json
Fractalistic
A framework agnostic, developer friendly wrapper around Fractal
Stars: ✭ 309 (-98.51%)
Mutual labels:  api, json
Datoji
A tiny JSON storage service. Create, Read, Update, Delete and Search JSON data.
Stars: ✭ 222 (-98.93%)
Mutual labels:  api, json
Laravel Json Api Paginate
A paginator that plays nice with the JSON API spec
Stars: ✭ 351 (-98.31%)
Mutual labels:  api, json
Allorigins
👽 Pull contents from any page as JSON via API
Stars: ✭ 343 (-98.34%)
Mutual labels:  api, json
Jsonapi Rails
Rails gem for fast jsonapi-compliant APIs.
Stars: ✭ 242 (-98.83%)
Mutual labels:  api, json
Dog Ceo Api
The API hosted at dog.ceo
Stars: ✭ 393 (-98.1%)
Mutual labels:  api, json
Horaires Ratp Api
Webservice pour les horaires et trafic RATP en temps réel
Stars: ✭ 232 (-98.88%)
Mutual labels:  api, json
Laravel Api Response Builder
Builds nice, normalized and easy to consume Laravel REST API JSON responses.
Stars: ✭ 433 (-97.91%)
Mutual labels:  api, json
Flask Restplus
Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 2,585 (-87.52%)
Mutual labels:  api, json
Toapi
Every web site provides APIs.
Stars: ✭ 3,209 (-84.51%)
Mutual labels:  api, json
Bilibili Api Collect
哔哩哔哩-API收集整理【不断更新中....】
Stars: ✭ 4,497 (-78.3%)
Mutual labels:  api, json
Jsonapi Rb
Efficiently produce and consume JSON API documents.
Stars: ✭ 219 (-98.94%)
Mutual labels:  api, json
Api
HeadHunter API: документация и библиотеки
Stars: ✭ 324 (-98.44%)
Mutual labels:  api, json
Polr
🚡 A modern, powerful, and robust URL shortener
Stars: ✭ 4,147 (-79.99%)
Mutual labels:  api, json

normalizr build status Coverage Status npm version npm downloads

📣 🤝 Maintainer help wanted

Install

Install from the NPM repository using yarn or npm:

yarn add normalizr
npm install normalizr

Motivation

Many APIs, public or not, return JSON data that has deeply nested objects. Using data in this kind of structure is often very difficult for JavaScript applications, especially those using Flux or Redux.

Solution

Normalizr is a small, but powerful utility for taking JSON with a schema definition and returning nested entities with their IDs, gathered in dictionaries.

Documentation

Examples

Quick Start

Consider a typical blog post. The API response for a single post might look something like this:

{
  "id": "123",
  "author": {
    "id": "1",
    "name": "Paul"
  },
  "title": "My awesome blog post",
  "comments": [
    {
      "id": "324",
      "commenter": {
        "id": "2",
        "name": "Nicole"
      }
    }
  ]
}

We have two nested entity types within our article: users and comments. Using various schema, we can normalize all three entity types down:

import { normalize, schema } from 'normalizr';

// Define a users schema
const user = new schema.Entity('users');

// Define your comments schema
const comment = new schema.Entity('comments', {
  commenter: user
});

// Define your article
const article = new schema.Entity('articles', {
  author: user,
  comments: [comment]
});

const normalizedData = normalize(originalData, article);

Now, normalizedData will be:

{
  result: "123",
  entities: {
    "articles": {
      "123": {
        id: "123",
        author: "1",
        title: "My awesome blog post",
        comments: [ "324" ]
      }
    },
    "users": {
      "1": { "id": "1", "name": "Paul" },
      "2": { "id": "2", "name": "Nicole" }
    },
    "comments": {
      "324": { id: "324", "commenter": "2" }
    }
  }
}

Dependencies

None.

Credits

Normalizr was originally created by Dan Abramov and inspired by a conversation with Jing Chen. Since v3, it was completely rewritten and maintained by Paul Armstrong. It has also received much help, enthusiasm, and contributions from community members.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].