Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Normalize your JSON:API response

License

NotificationsYou must be signed in to change notification settings

guillaumebriday/json-api-response-converter

Repository files navigation

Donate

Features

  • Very small
  • No dependencies
  • Easy to use
  • Compatible withVuex ORM

Getting started

Install

$ npm install json-api-response-converter --save# or$ yarn add json-api-response-converter

Usage

importJsonApiResponseConverterfrom'json-api-response-converter'constresponse={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!'}}]}constdata=newJsonApiResponseConverter(response).formattedResponseconsole.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 thetests 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 withJest:

$ yarntest# or npm run test

Check the syntax withESLint:

$ 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 theMIT License.

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp