Creating observables from a nested json.

This commit is contained in:
Nedyalko Nikolov
2016-07-18 17:34:17 +03:00
parent d3986780ca
commit 48a57bdaf3
2 changed files with 45 additions and 0 deletions

View File

@@ -56,6 +56,9 @@ export class Observable implements definition.Observable {
this._map = new Map<string, Object>();
for (var prop in json) {
if (json.hasOwnProperty(prop)) {
if (!Array.isArray(json[prop]) && typeof json[prop] === 'object') {
json[prop] = new Observable(json[prop]);
}
this._defineNewProperty(prop);
this.set(prop, json[prop]);
}