import { JsonData } from "../client" ; import { EntityData } from '../entity/entity' ; import { SchemaDefinition } from "../schema/schema-definitions" ; export default class JsonConverter { private schemaDef : SchemaDefinition ; constructor ( schemaDef ) { this . schemaDef = schemaDef ; } toJsonData ( entityData ) { return entityData ; } toEntityData ( jsonData ) { let entityData = { } ; if ( jsonData === null ) return entityData ; for ( let field in this . schemaDef ) { let value = jsonData [ field ] ; if ( value !== undefined && value !== null ) entityData [ field ] = value ; } return entityData ; } }