How to use the @ember-data/serializer/transform.extend function in @ember-data/serializer

To help you get started, we’ve selected a few @ember-data/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 hashicorp / vault / ui / app / transforms / object.js View on Github external
import Transform from '@ember-data/serializer/transform';
import { typeOf } from '@ember/utils';
/*
  DS.attr('object')
*/
export default Transform.extend({
  deserialize: function(value) {
    if (typeOf(value) !== 'object') {
      return {};
    } else {
      return value;
    }
  },
  serialize: function(value) {
    if (typeOf(value) !== 'object') {
      return {};
    } else {
      return value;
    }
  },
});
github hashicorp / vault / ui / app / transforms / array.js View on Github external
import Transform from '@ember-data/serializer/transform';
import { isArray, A } from '@ember/array';
/*
  This should go inside a globally available place for all apps

  DS.attr('array')
*/
export default Transform.extend({
  deserialize(value) {
    if (isArray(value)) {
      return A(value);
    } else {
      return A();
    }
  },
  serialize(value) {
    if (isArray(value)) {
      return A(value);
    } else {
      return A();
    }
  },
});

@ember-data/serializer

Provides Legacy JSON, JSON:API and REST Implementations of the Serializer Interface for use with @ember-data/store

MIT
Latest version published 18 days ago

Package Health Score

89 / 100
Full package analysis