angular.fromJson
函数 angular.fromJson
将反序列化有效的 JSON 字符串并返回 Object 或 Array。
angular.fromJson(字符串|对象)
请注意,此函数不仅限于字符串,它将输出传递给它的任何对象的表示。
例子:
angular.fromJson("{\"yogurt\": \"strawberries\"}")
// Object {yogurt: "strawberries"}
angular.fromJson('{jam: "raspberries"}')
// will throw an exception as the string is not a valid JSON
angular.fromJson(this)
// Window {external: Object, chrome: Object, _gaq: Y, angular: Object, ng339: 3…}
angular.fromJson([1, 2])
// [1, 2]
typeof angular.fromJson(new Date())
// "object"