Thursday, March 22, 2007


wiki en and wiki ru

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language.

Sample JSON

"data": "The markup of fragment",
"portlets": [
"wid": "8759875984237598347",
"title": "заголовок",
"mode": "VIEW",
"state": "NORMAL",
"content": "The markup of portlet",

Sample JavaScript, where is req.responseText - is the JSON response.

var data_object = eval("(" + req.responseText + ")");
alert(" = " +;
var frag =;
var portlets = data_object.portlets;
var portletLength = portlets.length;
for (var i = 0; i < portletLength; i++) {
document.getElementById("p" + portlets[i].wid + "title").innerHTML = portlets[i].title;
document.getElementById("p" + portlets[i].wid + "content").innerHTML = portlets[i].content;


JSON official
JSON in JavaScript
JSON in Java
Generate JSON from XML to use with Ajax
Генерирование JSON из XML для использования с Ajax

No comments: