想必有些人更愿意出于自己的目的使用 JSON 格式的数据。如果我试图构建某种动态 Javascripty 文档系统,我可以想象选择使用 JSON 作为以可管理的格式从后端将文档获取到客户端的方式,如果由于某种原因 HTML 或 XML 没有似乎是更好的选择。
I assume you're talking about the SerializingHTMLBuilder, in which case I think the answer might be that there isn't necessarily a specific purpose in mind. Rather many things provide conversion routines of various kinds with a "loads/dumps" API convention, and the json module (known as simplejson before it was brought standard library in 2.6) is but one of many such packages.
Presumably some people would prefer to work with data in JSON format for their own purposes. If I were trying to build some sort of dynamic Javascripty documentation system, I could well imagine choosing to use JSON as the way to get documentation from the backend out to the client in a manageable format, if for some reason HTML or XML didn't seem like the better option.
发布评论
评论(2)
正如 文档 所说,
json 是一种与语言无关的数据交换的好简单方法,所以,为什么不呢?-)
As the docs say, it's
json's a good simple way for language-agnostic data interchange, so, why not?-)
我假设您正在谈论 SerializingHTMLBuilder,其中在这种情况下,我认为答案可能是头脑中不一定有特定的目的。相反,许多东西提供了各种带有“加载/转储”API 约定的转换例程,以及
json
模块(在 2.6 中引入标准库之前称为simplejson
)只是许多此类软件包之一。想必有些人更愿意出于自己的目的使用 JSON 格式的数据。如果我试图构建某种动态 Javascripty 文档系统,我可以想象选择使用 JSON 作为以可管理的格式从后端将文档获取到客户端的方式,如果由于某种原因 HTML 或 XML 没有似乎是更好的选择。
I assume you're talking about the SerializingHTMLBuilder, in which case I think the answer might be that there isn't necessarily a specific purpose in mind. Rather many things provide conversion routines of various kinds with a "loads/dumps" API convention, and the
json
module (known assimplejson
before it was brought standard library in 2.6) is but one of many such packages.Presumably some people would prefer to work with data in JSON format for their own purposes. If I were trying to build some sort of dynamic Javascripty documentation system, I could well imagine choosing to use JSON as the way to get documentation from the backend out to the client in a manageable format, if for some reason HTML or XML didn't seem like the better option.