mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 11:54:10 +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;
 |