mirror of
https://github.com/strapi/strapi.git
synced 2025-07-21 07:57:45 +00:00
17 lines
269 B
JavaScript
17 lines
269 B
JavaScript
'use strict';
|
|
|
|
const Field = require('./field');
|
|
|
|
class JSONField extends Field {
|
|
toDB(value) {
|
|
return JSON.stringify(value);
|
|
}
|
|
|
|
fromDB(value) {
|
|
if (typeof value === 'string') return JSON.parse(value);
|
|
return value;
|
|
}
|
|
}
|
|
|
|
module.exports = JSONField;
|