import { Type } from './Type' ; import type { Platform } from '../platforms' ; import type { EntityProperty } from '../typings' ; import { Utils } from '../utils' ; export class JsonType extends Type < unknown , string | null > { convertToDatabaseValue ( value , platform ) { if ( platform . convertsJsonAutomatically ( true ) || value === null ) { return value as string ; } return JSON . stringify ( value ) ; } convertToJSValue ( value , platform ) { if ( ! platform . convertsJsonAutomatically ( ) && Utils . isString ( value ) ) { return JSON . parse ( value ) ; } return value ; } getColumnType ( prop , platform ) { return platform . getJsonDeclarationSQL ( ) ; } }