Ghost/ghost/admin/app/transforms/json-string.js

13 lines
358 B
JavaScript
Raw Normal View History

import Transform from '@ember-data/serializer/transform';
export default class JsonString extends Transform {
deserialize(serialized) {
let _serialized = serialized === '' ? null : serialized;
return JSON.parse(_serialized);
}
serialize(deserialized) {
return deserialized ? JSON.stringify(deserialized) : null;
}
}