1.2.10 • Published 3 years ago

@disruptph/json-api-normalizer v1.2.10

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

@disruptph/json-api-normalizer

This is basically just re-exporting the json-api-normalizer. The only difference is that this package includes a typescript type definition.

Usage

import normalize from '@disruptph/json-api-normalizer';

const jsonApiData = {
  data: {
    id: '1',
    type: 'user'
    attributes: {
      name: 'John Doe',
      age: '25',
    },
    relationships: {
      posts: {
        data: [
          {
            id: '1',
            type: 'post'
          }
        ]
      }
    }
  },
  included: [
    {
      id: '1',
      type: 'post',
      attributes: {
        title: 'Hello World',
      }
    }
  ],
};

normalize(jsonApiData);

// Result:
// {
//   user: {
//     1: {
//       id: '1',
//       type: 'user'
//       attributes: {
//         name: 'John Doe',
//         age: '25',
//       },
//       relationships: {
//         posts: {
//           data: [
//             {
//               id: '1',
//               type: 'post'
//             }
//           ]
//         }
//       }
//     }
//   },
//   business: {
//     1: {
//       id: '1',
//       type: 'post',
//       attributes: {
//         title: 'Hello World',
//       }
//     }
//   }
// }
1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago