All Projects → guillaumebriday → json-api-response-converter

guillaumebriday / json-api-response-converter

Licence: MIT license
Normalize your JSON:API response

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to json-api-response-converter

Vox
Swift JSON:API client framework
Stars: ✭ 47 (+123.81%)
Mutual labels:  json-api, json-api-normalizer
json-api-react-redux-example
React Application With Redux And JSON API
Stars: ✭ 25 (+19.05%)
Mutual labels:  json-api, json-api-normalizer
Json Apis With Github
🔨 Tool to make Simple and Quick JSON APIs with GitHub.
Stars: ✭ 240 (+1042.86%)
Mutual labels:  json-api
ck-analytics
Collective Knowledge repository with actions to unify the access to different predictive analytics engines (scipy, R, DNN) from software, command line and web-services via CK JSON API:
Stars: ✭ 35 (+66.67%)
Mutual labels:  json-api
drupal-jsonapi-params
A package to manage json-api params
Stars: ✭ 42 (+100%)
Mutual labels:  json-api
Api Generator
PHP-code generator for Laravel framework, with complete support of JSON-API data format
Stars: ✭ 244 (+1061.9%)
Mutual labels:  json-api
php-serializer
Serialize PHP variables, including objects, in any format. Support to unserialize it too.
Stars: ✭ 47 (+123.81%)
Mutual labels:  json-api
Crnk Framework
JSON API library for Java
Stars: ✭ 234 (+1014.29%)
Mutual labels:  json-api
Characters of the Three Kingdoms
3️⃣ Characters of the Three Kingdoms - 三国人物结构化数据
Stars: ✭ 100 (+376.19%)
Mutual labels:  json-api
fn
No description or website provided.
Stars: ✭ 28 (+33.33%)
Mutual labels:  json-api
json-api
Framework agnostic JSON API serialisation and deserialisation
Stars: ✭ 40 (+90.48%)
Mutual labels:  json-api
druxt.js
The Fully Decoupled Drupal Framework
Stars: ✭ 96 (+357.14%)
Mutual labels:  json-api
Hotels server
酒店预订系统后台管理系统
Stars: ✭ 249 (+1085.71%)
Mutual labels:  json-api
JsonApiBundle
Integration of JSON API with Symfony using JMS Serializer
Stars: ✭ 56 (+166.67%)
Mutual labels:  json-api
Jsonapi Rails
Rails gem for fast jsonapi-compliant APIs.
Stars: ✭ 242 (+1052.38%)
Mutual labels:  json-api
fire
An idiomatic micro-framework for building Ember.js compatible APIs with Go.
Stars: ✭ 56 (+166.67%)
Mutual labels:  json-api
Iotwifi
Raspberry Pi (arm) wifi configuration container. Configure and control wifi connectivity with a JSON based REST api.
Stars: ✭ 236 (+1023.81%)
Mutual labels:  json-api
rest-api
Laravel restfull api boilerplate
Stars: ✭ 57 (+171.43%)
Mutual labels:  json-api
xijs
A business - oriented scene Js Library
Stars: ✭ 91 (+333.33%)
Mutual labels:  json-api
example-golang-todo
Golang API backend powering a TodoList app
Stars: ✭ 33 (+57.14%)
Mutual labels:  json-api

JSON:API Response Converter

Donate

Features

  • Very small
  • No dependencies
  • Easy to use
  • Compatible with Vuex ORM

Getting started

Install

$ npm install json-api-response-converter --save

# or

$ yarn add json-api-response-converter

Usage

import JsonApiResponseConverter from 'json-api-response-converter'

const response = {
  data: [
    {
      id: '1',
      type: 'articles',
      attributes: {
        title: 'This project is awesome'
      },
      relationships: {
        author: {
          data: { id: '1', type: 'author' }
        },

        comments: {
          data: [
            { id: '1', type: 'comment' },
            { id: '2', type: 'comment' }
          ]
        }
      }
    }
  ],

  included: [
    {
      id: '1',
      type: 'author',
      attributes: {
        name: 'Anakin'
      }
    },
    {
      id: '1',
      type: 'comment',
      attributes: {
        body: 'First!'
      }
    },
    {
      id: '2',
      type: 'comment',
      attributes: {
        body: 'Second!'
      }
    }
  ]
}

const data = new JsonApiResponseConverter(response).formattedResponse

console.log(data)
/**
[
  {
    id: 1,
    title: 'This project is awesome',

    author: {
      id: 1,
      name: 'Anakin'
    },

    comments: [
      {
        id: 1,
        body: 'First!'
      },
      {
        id: 2,
        body: 'Second!'
      }
    ]
  }
]
*/

Many edges cases are tested in the tests folder

Development

$ git clone https://github.com/guillaumebriday/json-api-response-converter
$ cd json-api-response-converter
$ yarn # or npm install

You can run tests with Jest:

$ yarn test # or npm run test

Check the syntax with ESLint:

$ yarn lint

Contributing

Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

Credits

Inspired by:

License

The gem is available as open source under the terms of the MIT License.

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].