浏览器原生 JSON 支持 (window.JSON) [英] Browser-native JSON support (window.JSON)

查看:44
本文介绍了浏览器原生 JSON 支持 (window.JSON)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些浏览器通过 window.JSON 对象安全有效地支持对象的 JSON 解析/序列化,但详细信息很难获得.任何人都可以指出正确的方向吗?这个对象公开的方法是什么?支持哪些浏览器?

I have seen references to some browsers natively supporting JSON parsing/serialization of objects safely and efficiently via the window.JSON Object, but details are hard to come by. Can anyone point in the right direction? What are the methods this Object exposes? What browsers is it supported under?

推荐答案

所有现代浏览器都支持原生 JSON 编码/解码(Internet Explorer 8+、Firefox 3.1+、Safari 4+ 和 Chrome 3+).基本上,JSON.parse(str) 将解析 str 中的 JSON 字符串并返回一个对象,而 JSON.stringify(obj) 将返回对象 obj 的 JSON 表示.

All modern browsers support native JSON encoding/decoding (Internet Explorer 8+, Firefox 3.1+, Safari 4+, and Chrome 3+). Basically, JSON.parse(str) will parse the JSON string in str and return an object, and JSON.stringify(obj) will return the JSON representation of the object obj.

有关MDN 文章的更多详细信息.

这篇关于浏览器原生 JSON 支持 (window.JSON)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆