import { Serializable } from '../models/interfaces/Serializable'; export class JsonSerializer { public static fromJSONArray>(items: any[], type: { new(): T; }): T[] { if (!items) { return new Array(); } const objectList: T[] = new Array(); for (let i = 0; i < items.length; i++) { objectList.push(new type().fromJSONObject(items[i])); } return objectList; } public static fromJSONObject>(item: any, type: { new(): T; }): T { if (!item) { return null; } return new type().fromJSONObject(item); } public static copy>(item: any, itemToCopy: any): T { if (!item) { return null; } return item.fromJSONObject(itemToCopy); } }