UNPKG

kitsu-core

Version:

Simple, lightweight & framework agnostic JSON:API (de)serialsation components

38 lines (37 loc) 929 B
/** * Deserialises a JSON-API response * * @param {Object} response The raw JSON:API response object * @returns {Object} The deserialised response * * @example <caption>Deserialise with a basic data object</caption> * deserialise({ * data: { * id: '1', * attributes: { liked: true } * }, * meta: { hello: 'world' } * }) // { data: { id: '1', liked: true }, meta: { hello: 'world' } } * * @example <caption>Deserialise with relationships</caption> * deserialise({ * data: { * id: '1', * relationships: { * user: { * data: { * type: 'users', * id: '2' } * } * } * }, * included: [ * { * type: 'users', * id: '2', * attributes: { slug: 'wopian' } * } * ] * }) // { data: { id: '1', user: { data: { type: 'users', id: '2', slug: 'wopian' } } } } */ export function deserialise(response: any): any;