JSON Tips

JSON allows the encoding of data structures into a serialized format that could easily be processed by all programming languages. If you have structured data in one place (arrays, structs, hashes, lists) and want to move it somewhere else you need some kind of cross-platform serialization format.

Parsing JSON Data

Use “data = eval(‘(‘ + req.responseText + ‘)’)” to get JSON data

Use “for (var i=0;i<data.myHash.length;i++){…“ to loop through the JSON hashmap

Use document.createTextNode(data.myHash[i].myTag.myKey) to get key/value pairs from the JSON hasmap

JSON Functions

JSONP is basically wrapping JSON in a callback script. So a return such as the following

callback({“IBM”:”82.53″});

allows you to include the call as a script tag, such as:

var script = document.createElement(“script”);

script.src = ‘http://remoteserver/stockquote?symbol=IBM&callback=renderQuotes’;

script.type = ‘text/javascript’;

document.body.appendChild(script);

This will dynamically add a script to our page which will call back the already existing function
renderQuotes in our page.

This technique is very useful if you are including Ajax widgets on
remote sites or using bookmarklets or GreaseMonkey scripts to pull information from remote servers.

References

JSON Documentation
JSON Lint
JSON Configuration for JavaScript
JSON Namespacing
Using On Demand Javascript with JSON
Using JSON for Flat File Data
Converting Between XML and JSON
XML2JSON-XSLT Project
MySQL to JSON
RSS to JSON converter
JSON and the Dynamic Script Tag: Easy, XML-less Web Services for JavaScript
Native JSON methods in IE8 JScript
Remote JSON: JSONP
Parsing JSON
Web Services Plus JSON
JSONRequest
JSON Cookies
JSON Pros and Cons
Limitations of JSON
Loading data into a Dojo table using JSON APIs
God Bless the Reinventers
http://www.ibm.com/developerworks/web/library/wa-ajaxintro10
http://www.ibm.com/developerworks/xml/library/x-xml2json/
http://www.ibm.com/developerworks/xml/library/x-xmlajaxpt3/index.html
http://www.ibm.com/developerworks/web/library/x-atom2json.html
http://www.ibm.com/developerworks/library/os-php-v523/index.html
http://www.ibm.com/developerworks/xml/library/x-xml2jsonphp/
http://www.ibm.com/developerworks/wikis/display/dominoappdev/Introduction+to+JSON
http://www.ibm.com/developerworks/library/wa-ajaxintro11.html
http://www.ibm.com/developerworks/xml/library/wa-cachejson.html
http://www.ibm.com/developerworks/java/library/j-grails11188/index.html
http://blogs.msdn.com/irenak/archive/2007/02/07/sysk-282-how-json-is-making-your-code-cleaner.aspx
http://www.25hoursaday.com/weblog/2007/01/02/JSONVsXMLBrowserSecurityModel.aspx
http://www.25hoursaday.com/weblog/2007/01/02/JSONVsXMLBrowserProgrammingModels.aspx
http://ajaxian.com/archives/jsonlib-json-extensions-a-la-e4x
http://rayfd.wordpress.com/2007/03/28/why-wont-eval-eval-my-json-or-json-object-object-literal/
http://www.mikechambers.com/blog/2006/03/28/tutorial-using-json-with-flex-2-and-actionscript-3
XML to JSONML Client-Side Proxy
JSONP Memory Leak
JSON, AJAX, and PHP
Binding Events with JSON
Mapping ATOM to JSON
RESTful JSON
XSLTJSON XML to JSON Transformation
JavaScript JSON Serialization
Native JSON Support is Required
JSON for Map/Reduce
JSON Serialization of Dates
.toJSONString() and Object.prototype
Cross-Domain Scripting
Buggy Native JSON
JSONPath – XPath for JSON

TrackBack URI

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.