mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 09:56:44 +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; |