import { IDataTableSerializer } from './IDataTableSerializer' ; import { DataTable } from './DataTable' ; class classdesc Saves and loads a  DataTable object to and from an json file.
  export class DataTableJsonSerializer implements IDataTableSerializer { readonly extension : string ; constructor ( ) { this . extension = "json" ; } /** Serializes the specified  DataTable object into a Buffer data.
     *  method serialize ( dataTable ) { return new Buffer ( JSON . stringify ( dataTable , null , 4 ) , 'utf8' ) ; } /** Deserializes the specified buffer data into a  DataTable object
     *  method deserialize ( data ) { return JSON . parse ( data . toString ( 'utf8' ) , DataTableJsonSerializer . JSONDataReviver ) ; } private static JSONDataReviver ( key , str ) { var result = str ; if ( typeof str === 'string' || str instanceof String ) { var parsedValue = DataTableJsonSerializer . parseDates ( str ) ; if ( parsedValue !== null ) { result = parsedValue ; } } return result ; } ; private static parseDates ( str ) { var result = null ; var dateParts = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.*(\d*)Z$/ . exec ( str ) ; if ( dateParts !== null ) { result = new Date ( Date . UTC ( + dateParts [ 1 ] , + dateParts [ 2 ] - 1 , + dateParts [ 3 ] , + dateParts [ 4 ] , + dateParts [ 5 ] , + dateParts [ 6 ] , + dateParts [ 7 ] ) ) ; } return result ; } }