JavaScript Object Notation.
[A ridiculous name. It should be called Lightweight Ecmascript Object Notation, or 'LEON' for short. ;-)]
Json代表着什么?
Javascript Object Notation。
【真是一个可笑的名字。它本该叫做轻量级的核心对象符号,或者简称'LEON'。;-)】
JSON is a syntax for passing around objects that contain name/value pairs, arrays and other objects.
Json意味着什么?
JSON是一种在对象之间传递数据的语法,这些对象一般包含name/value对,数组或其他的对象。
Here's a tiny scrap of JSON:
这是一个JSON的小片段:
{"skillz": { "web":[ {"name": "html", "years": "5" }, {"name": "css", "years": "3" }], "database":[ {"name": "sql", "years": "7" }] }}
You got that? So you'd recognise some JSON if you saw it now? Basically:
你看得懂吗?你因此想起之前的一些JSON印象?JSON主要有以下特点:
(Or if you're as old as me, think "'.INI' files, with hierarchy.")
(Or if you're a smug lisp weenie, think "S-expressions", and just be smug.)
When you're writing ajax stuff, if you use JSON, then you avoid hand-writing xml. This is quicker.
在你写ajax的东西的时候,如果使用JSON,那你将不要手写任何xml代码。这样子写代码很快捷。
Again, when you're writing ajax stuff, which looks easier? the XML approach or the JSON approach:
此外,当你又在编写关于ajax的东西,哪一个看起来更简单一些呢:XML的方法和JSON的方法?
Nah, not strictly.
嗯,不完全是。
JSON is about as object oriented as VB6. It provides a nice encapsulation technique, that you can use for separating values and functions out, but it doesn't provide anything inheritence, polymorphism, interfaces, or OO goodness like that.
JSON的面向对象就像VB6的面向对象一样。它提供了一个很好的封装机制,可以用来区分不同的值和不同的函数,但它不支持继承、多态、接口和面向对象的其他精华等。
It is certainly a step in the right direction though, making javascript easier to maintain, share and reuse.
这绝对是走向正确方向的坚实一步,使得javascrip更易于维护、共享和重用。
Thomas Frank wrote a nifty little javascript library called classyJSON for adding inheritance and scoping capabilities to JSON code.
托马斯·弗兰克写了小巧漂亮的javascript库叫做classyJSON,这个库使JSON代码支持继承和动态作用域。
Yes and no. On the server-side you can easily serialize/deserialize your objects to/from JSON. For .net
programmers you can use libraries like Json.net to do this automatically for you (using reflection i assume), or you can generate your own custom code to perform it even faster on a case by case basis.
是的也不是的。在服务器端,可以从JSON序列化或反序列化一个对象。对于.net程序员来说,可以使用Json.net库,这个库会为你自动处理这些事情(在我假设使用映射的前提下),或者你也可以根据不同的情况来生成你自定义的代码来完成这件事情,这样甚至会执行得更快。
As near as a I can tell, JSON was invented by a guy called Douglas Crockford. Read his website if you want, he's pretty funny.
据我所知,道格拉斯·克洛克福特发明了JSON。感兴趣的话,去看看他的网站吧,他真是一个有趣的人呵。
(Retrieved from Delicious using JSON!)
(从网站"美味的JSON"搜刮过来的)
I've only tinkered with this stuff for a few minutes -- so I've probably said some completely wrong things. If so, please leave a comment, telling me what an idiot i am. I'll be happy to correct any specific mistakes. Best of luck!
我只花了一些时间在这篇文章上面,因此,也可能顺口就说出了完全错误的东西。如果这样,请给我留言,告诉我是一个多么大的傻瓜。我很愿意修改任何一个细节上的错误。祝你好运!
(Side Note:If you replace { and } with "<" and "/>", and you replace ":" with "/"... you'd have something very similar to gaXml. Funny old world.
(注:如果你把"{"和"}"替换成"<"和"/>",并把":"换成"/"……你将得到一个和gaXml(?)非常相似的东西。过去的那个gaXml世界也是多么有趣啊。
(Other side note: Jason and Ajax were both mythical greek heroes. Prediction: other forthcoming technology jargon will include: Heracles, Perseus, Deucalion, Theseus and Bellerophon.)
(又注:Jason(伊阿宋)和Ajax(阿加克斯)都是希腊神话中虚构的英雄。在这里顺便预言一下:接下来新出现的技术将会包括:赫拉克勒斯(Heracles)、珀尔修斯(Perseus)、丢卡利翁(Deucalion)、提修斯(Theseus )和柏勒罗丰(Bellerophon)。)