How to use the jsonapi-serializer.Deserializer function in jsonapi-serializer

To help you get started, we’ve selected a few jsonapi-serializer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shoutem / cli / src / clients / json-api-client.js View on Github external
import _ from 'lodash';
import { Deserializer } from 'jsonapi-serializer';
import * as logger from '../services/logger';

const deserializer = new Deserializer({
  keyForAttribute: 'camelCase'
});

// jsonapi-serializer seems to ignore non-included relationships no matter what its docs say
// therefore, support an option to use our own deserialization when specified(default still jsonapi-serializer)
function deserializePlainSingle(json) {
  const relationships = json.relationships;
  const relationshipKeys = _.keys(relationships);

  const relationshipIds = {};
  _.forEach(relationshipKeys, key => {
    relationshipIds[key] = _.get(relationships[key], 'data.id');
  })

  return {
    ...relationshipIds,
github DefinitelyTyped / DefinitelyTyped / types / jsonapi-serializer / jsonapi-serializer-tests.ts View on Github external
import { Serializer, Deserializer, Error } from "jsonapi-serializer";

declare let firstName: string;
declare let lastName: string;

const UserSerializer = new Serializer("users", {
    id: "id",
    attributes: ["firstName", "lastName"],
    keyForAttribute: "camelCase",
    pluralizeType: false
});

const users = UserSerializer.serialize({ firstName, lastName });

const UserDeserializer = new Deserializer({
    id: "id",
    keyForAttribute: "camelCase",
    pluralizeType: false,
    typeAsAttribute: true
});

UserDeserializer.deserialize(users);

new Error({
    code: "_code",
    detail: "_detail",
    id: "_id",
    links: {
        about: "_about"
    },
    source: {
github ForestAdmin / lumber / deserializers / user.js View on Github external
const JSONAPIDeserializer = require('jsonapi-serializer').Deserializer;

module.exports = new JSONAPIDeserializer({
  keyForAttribute: 'camelCase',
});
github forest-watcher / forest-watcher / app / offline / effect.js View on Github external
      .then(data => (canDeserialize(data) ? new JSONAPIDeserializer(deserializeOptions).deserialize(data) : data))
      .catch(err => {
github ForestAdmin / lumber / deserializers / environment.js View on Github external
const JSONAPIDeserializer = require('jsonapi-serializer').Deserializer;

module.exports = new JSONAPIDeserializer({
  keyForAttribute: 'camelCase',
  projects: {
    valueForRelationship: (relationship, included) => included,
  },
});
github resource-watch / resource-watch / services / FaqsService.js View on Github external
      .then(response => new Deserializer({
        keyForAttribute: 'underscore_case'
      }).deserialize(response, (err, faqs) => sortBy(faqs, 'order')));
  }
github resource-watch / resource-watch / services / ToolsService.js View on Github external
onSuccess: (response) => {
          new Deserializer({
            keyForAttribute: 'underscore_case'
          }).deserialize(response, (err, tools) => {
            resolve(sortBy(tools, 'name'));
          });
        },
        onError: (error) => {
github ForestAdmin / lumber / deserializers / project.js View on Github external
const JSONAPIDeserializer = require('jsonapi-serializer').Deserializer;

module.exports = new JSONAPIDeserializer({
  keyForAttribute: 'camelCase',
  environments: {
    valueForRelationship: (relationship, included) => included,
  },
  renderings: {
    valueForRelationship: (relationship, included) => included,
  },
});
github resource-watch / resource-watch / services / pages.js View on Github external
onSuccess: (response) => {
          new Deserializer({ keyForAttribute: 'underscore_case' }).deserialize(response, (err, pages) => {
            resolve(sortBy(pages, 'name'));
          });
        },
        onError: (error) => {
github resource-watch / resource-watch / services / ToolsService.js View on Github external
onSuccess: (response) => {
          new Deserializer({
            keyForAttribute: 'underscore_case'
          }).deserialize(response, (err, tool) => {
            resolve(tool);
          });
        },
        onError: (error) => {

jsonapi-serializer

A Node.js framework agnostic library for serializing your data to JSON API

MIT
Latest version published 9 months ago

Package Health Score

67 / 100
Full package analysis