Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { isEmpty, typeOf } from '@ember/utils';
import DS from 'ember-data';
export default DS.Transform.extend({
serialize: function(value) {
return value ? JSON.stringify(value) : '{}';
},
deserialize: function(value) {
if (isEmpty(value)) {
return {};
}
if (typeOf(value) === "object") {
return value;
}
if (typeOf(value) === 'string') {
return JSON.parse(value);
}
}
});
import Ember from 'ember';
import DS from 'ember-data';
const {
get,
isNone
} = Ember;
const keys = Object.keys || Ember.keys;
export default DS.Transform.extend({
deserialize: function(serialized) {
if (isNone(serialized)) { return []; }
return keys(serialized).map(function (attachmentName) {
let attachment = serialized[attachmentName];
return Ember.Object.create({
name: attachmentName,
content_type: attachment.content_type,
data: attachment.data,
stub: attachment.stub,
length: attachment.length,
digest: attachment.digest,
});
});
},
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize(serialized) {
if (!serialized) {
return serialized;
}
let ret = Ember.A();
let parser = new DOMParser();
let xmlDoc = parser.parseFromString(serialized, 'text/xml');
if (xmlDoc) {
let items = xmlDoc.getElementsByTagName('TypeMap');
if (items.length > 0) {
let arr = items[0].getElementsByTagName('*');
for (let item of arr) {
let obj = {
name: item.tagName
import { inject as service } from '@ember/service';
import { get } from '@ember/object';
import { isEmpty } from '@ember/utils';
import DS from 'ember-data';
import uuid from 'uuid';
export default DS.Transform.extend({
store: service(),
deserialize(serialized) {
if (isEmpty(serialized)) {
return serialized;
}
return serialized.map((customField) => {
let store = this.get('store');
let record = store.push({
data: {
id: uuid.v4(),
type: 'custom-field',
attributes: customField
}
});
return record;
import DS from 'ember-data';
import Ember from 'ember';
export default DS.Transform.extend({
serialize: function(value) {
return value && JSON.stringify(value);
},
deserialize: function(value) {
if (Ember.isEmpty(value)) {
return {};
}
if (Ember.typeOf(value) === "object") {
return value;
}
if (Ember.typeOf(value) === 'string') {
return JSON.parse(value);
}
}
});
import EmberObject from '@ember/object';
import { inject as service } from '@ember/service';
import { isEmpty } from '@ember/utils';
import DS from 'ember-data';
export default DS.Transform.extend({
store: service(),
deserialize(serialized) {
if (isEmpty(serialized)) {
return serialized;
}
let customFormKeys = Object.keys(serialized);
let deserialized = EmberObject.create();
customFormKeys.forEach((customFormId) => {
deserialized.set(customFormId, EmberObject.create(serialized[customFormId]));
});
return deserialized;
},
serialize(deserialized) {
return deserialized;
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize(serialized) {
return (serialized === null || serialized === undefined) ? true : serialized;
},
serialize(deserialized) {
return deserialized;
}
});
import { isEmpty } from '@ember/utils';
import DS from 'ember-data';
/*
DS.attr('integer')
*/
export default DS.Transform.extend({
deserialize: function(value) {
if (isEmpty(value)) {
return null;
} else {
return value;
}
},
serialize: function(value) {
if (isEmpty(value)) {
return null;
} else {
return value;
}
},
});
import DS from 'ember-data';
export default DS.Transform.extend({
serialize: function(value) {
return value ? value.toJSON() : null;
},
deserialize: function(value) {
return moment(value);
}
});
import { get } from '@ember/object';
import { isEmpty } from '@ember/utils';
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize(serialized) {
if (isEmpty(serialized)) {
return [];
}
return serialized.map((description) => {
return {
description
};
});
},
serialize(deserialized) {
if (isEmpty(deserialized)) {
return [];
}