于是晚上我乘坐了一辆慢腾腾的公交回到家(周五通常都是很慢),然后给自己找了一大堆关于JSON资料。所以我可以文雅的带你进入JSON的大门。
这就开始了 …
JavaScript Object Notation.
[一个滑稽的名字。它应该被称作Lightweight Ecmascript Object Notation, 或简称 'LEON'。 ]
JSON是一种传递对象的语法,对象可以是name/value对,数组和其他对象。
下面是一小段JSON代码:
{"skillz": { "web":[ {"name": "html", "years": "5" }, {"name": "css", "years": "3" }], "database":[ {"name": "sql", "years": "7" }] }}
你看懂了吧?那么当你再看到它时就知道它是JSON了。主要部分:
(如果你跟我一样老,可以把它想成有层次关系的'.INI'文件)
(如果你是个自以为是的Lisp小丑,可以把它想成”S-expressions”,自以为是吧)
当你写ajax之类的东西时,如果你使用JSON,你就勉去了手工拼写XML。更迅速。
同样,当你写ajax之类的东西时,怎样最简单?XML方式还是JSON方式:
No, strictly speaking, no.
It’s like object-oriented in VB6. It provides a good encapsulation mechanism, you can use it to separate data and methods, but it does not provide any inheritance, polytype, interface, or other similar object-oriented things
Obviously, it is a step forward in making JavaScript easier to maintain, analyze and reuse.
Thomas Frank wrote a flexible javascript library called classyJSON, which adds features such as inheritance and definition scope to JSON code.
Yes and no. On the server side you can easily serialize objects to JSON and vice versa. For .net
, programmers can use a class library like Json.net to automate these operations (I guess using reflection mechanism), or you can use your own program to do these things, which may be faster some.
As far as I know, JSON was invented by a guy named Douglas Crockford. If you like it, you can take a look at his website, he is very interesting.
(Scraped from Delicious using JSON!)
That’s all I’ve got a few minutes to sort out – all I’ve said is that some of the stuff I’ve said may be completely wrong. If so, please leave me a comment and tell me how stupid I am. I will happily correct any mistakes. Good luck!
(Side note: If you replace { and } with "<" and "/>" and ":" with "/"... you'll get something very much like gaXml Stuff. Interesting world
(Side Note 2: Jason and Ajax are both heroes from Greek mythology. Preview: Other upcoming tech junk includes: Heracles, Perseus, Deucalion, Theseus
and Bellerophon )