Created
August 12, 2016 10:13
-
-
Save KoKuToru/a9ff1da8f77516ecc802427ef858e1ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jsonToEmber(obj) { | |
if (obj instanceof Array) { | |
return Ember.A(obj.map(y => jsonToEmber(y))); | |
} else if (obj instanceof Object) { | |
let tmp = {}; | |
for (const x of Object.keys(obj)) { | |
if (obj[x] instanceof Array) { | |
tmp[x] = Ember.A(obj[x].map(y => jsonToEmber(y))); | |
} else if (obj[x] instanceof Object) { | |
tmp[x] = jsonToEmber(obj[x]); | |
} else { | |
tmp[x] = obj[x]; | |
} | |
} | |
return Ember.Object.create(tmp); | |
} else { | |
return obj; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment