November 09, 2005
JSON - Simple, Elegant Data Structures for Javascript/AJAX
I've used this technique recently to develop a project that uses client-side Javascript to handle all of its data and business logic. I didn't know, until reading about it on Anil Dash's excellent treatise on "technologies and techniques are going to be popular in the coming months and into the next year", that this technique had a name. JSON (JavaScript Object Notation) is an incredibly useful technique for building simple, powerful data structures into Javascript programs. In this day of AJAX and other powerful ways to build outstanding interfaces and applications using client-side code, JSON is more useful than ever.In a nutshell, you can define a data object explicitly like this:
var myData = {
"title" : "In the Bubble: Designing in a Complex World",
"author" : "John Thackara",
"chapters" : [
{ "name" : "Lightness", "length" : "32", "finished" : true },
{ "name" : "Speed", "length" : "23", "finished" : true },
{ "name" : "Mobility", "length" : "41", "finished" : false }
]
}
myData.title evaluates to "In the Bubble: Designing in a Complex World"
myData.chapters[0].name evaluates to "Lightness"
or assign var chaps = myData.chapters; and then do chaps[1].length to get "23"
var myObject = eval('(' + aJSONtext + ')');
Posted by larryb at 05:44 AM [permanent link] | Comments (0)
| TrackBacks (0)
Category: Web and Software Development
Category: Web and Software Development
TrackBack URL for this entry:
http://www.learningapi.com/cgi-bin/mt-tb.cgi/71
Listed below are links to weblogs that reference 'JSON - Simple, Elegant Data Structures for Javascript/AJAX' from learningAPI.com: Media and Learning Technology - Larry Bouthillier.
http://www.learningapi.com/cgi-bin/mt-tb.cgi/71
Listed below are links to weblogs that reference 'JSON - Simple, Elegant Data Structures for Javascript/AJAX' from learningAPI.com: Media and Learning Technology - Larry Bouthillier.
Search
Archives
Recent Entries
Facebook and Academic Institutions - Content or Context?
Video Transcript Browsing Interface
The New RealPlayer 11 - A First Look
Is RealPlayer going to make a comeback?
Is Amazon's S3 the cheapest streaming video hosting out there?
Image, Audio & Video Search - Reading Content and Context
e-Learning 2.0 - The End of the Course?
Online Video and Web 2.0 - What's missing?
Fundamentals of Website Development - Course Resources
A Full-Featured Flash Video Player
Video Transcript Browsing Interface
The New RealPlayer 11 - A First Look
Is RealPlayer going to make a comeback?
Is Amazon's S3 the cheapest streaming video hosting out there?
Image, Audio & Video Search - Reading Content and Context
e-Learning 2.0 - The End of the Course?
Online Video and Web 2.0 - What's missing?
Fundamentals of Website Development - Course Resources
A Full-Featured Flash Video Player
Author Links
About the author
Speaking Engagements
Streaming and Multimedia Articles and Tutorials
My Harvard Business School Bio page
Blogroll
Digital Media Bulletin - Jose Alvear
ResearchForward - Michael J. Hemment
BusinessOfVideo.com
Online Video Punch
The Learning Circuits Blog
Elatable - Bradley Horowitz
Harold Jarche
HBS Prof. Andy McAfee on Web 2.0
DV for Teachers
SciTech Daily Review
Quirksmode - Javascript & AJAX
Educational Technology & Life
Jon Udell
Learning Technology - Denis Saulnier
Weblog Categories
Digital Restrictions Management
eLearning & Instructional Technology
Innovative Technology
Misc
Personal Video Publishing
Streaming Media
Streaming Media Technology Tips
Video and Multimedia Technology
Web and Software Development
Weblogs
External Links
