Dustin Diaz has just posted JSON for the masses, an excellent article that will get JavaScript developers thinking about objects and how they can lead to organized, maintainable code. I just wanted to second his post, and say I’m on the JSON train as well. Go ahead and read Dustin’s post, and if you want to get on board I suggest trying the following steps to get yourself comfortably acquainted with JSON:

  • Become familiar with the official JSON in JavaScript page. Give it a good read, and bookmark it.

  • Using the JSON object example from the official page, try to send it to the server with JSON.stringify(). I use the code file given on the official page to do this.

  • Try to read the JSON string on the server, and convert it into a server side object. I use PHP, so JSON-PHP is my helper file of choice. Once you’ve got a PHP object, practice looping through it and accessing the data inside.

  • Using your PHP object, loop through the entire thing and learn how to write a JSON string both manually and using the JSON-PHP encode function. Then echo the results out, so that an Ajax call can pick up the response.

  • With an Ajax call, request the data from the PHP page and read it in using eval() or parse(). At this point, you will have a copy of the object from step 2. Learn how to loop through this object, and read the different values. Prototype Meets Ruby: A Look at Enumerable, Array and Hash was a must read for me at this step. If you’re not using Prototype, find your libraries equivalent, or write your own home grown solution.

And that should get you started. The steps above will lead to some frustration when they don’t work the first time. If you get through it, you will have a new tool that will become invaluable as you begin making more JavaScript heavy sites.

HTML Form Builder
Ryan Campbell

More Love For JSON by Ryan Campbell

This entry was posted 5 years ago and was filed under Notebooks.
Comments are currently closed.


  1. Michal Migurski · 5 years ago

    It’s great to read this. Interestingly, there’s currently a debate in the JSON Y! group about a new name for “AJAX” that drops the ‘X’ in favor of something more appropriate to JSON. My personal feeling is that this branding exercise is unnecessary - JSON is so self-evidently optimal for this stuff that it doesn’t need to be sold to anybody.

  2. Dustin Diaz · 5 years ago

    @Ryan: Choo choo… Welcome aboard. I’ve actually been meaning to write about this for a while, so I’m glad you’re on the train with me. I hope others will see its usefulness in due time.

    @Michael: I could see something more like AJASON. I’ll talk to the guys and see what we’re coming up with.

  3. real · 5 years ago

    Dude, this’ll be awesome

  4. P.J. Onori · 5 years ago

    It was definitely a great article by Dustin. For myself, Javascript seems so much more attractive an option with JSON.

  5. Guest · 5 years ago

    > a new name for “AJAX” that drops the ‘X’ in > favor of something more appropriate to JSON

    I sure hope it isn’t “AJAJ” cuz JAJ in Corean means penis…

  6. Maikel · 5 years ago

    Hello, Very good article. Javascript powered by JSON and AJAX is the solution to many problems with dynamic programming.

    Thank you

  7. Dan · 4 years ago

    Everyone needs a hug.