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"