Merge pull request #2469 from NativeScript/nnikolov/NestedObservables

Creating observables from a nested json.
This commit is contained in:
Nedyalko Nikolov
2016-07-19 18:04:12 +03:00
committed by GitHub
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]);
}