Chapter 10. JSON: SON of JavaScript

image with no caption

JavaScript, objects, and notation, oh my!

If you ever need to represent objects in your JavaScript, then you’re going to love JSON, JavaScript Standard Object Notation. With JSON, you can represent complex objects and mappings with text and a few curly braces. Even better, you can send and receive JSON from other languages, like PHP, C#, Python, and Ruby. But how does JSON stack up as a data format? Turn the page and see...

image with no caption

Joe: I think we might have different definitions of flawless, man. Two DOM trees to work with, and dealing with whitespace in the server’s response?

Jim: That’s a good point, Frank. Did you even check for whitespace nodes?

Frank: No, but that’s easy enough to add in—

Joe: And your code will get even more convoluted.

Frank: Hey, at least my code works. And that CSV stuff was a total bust.

Jim: It worked great! At least... well, it worked pretty well until we had data where the structure changed depending on the item.

Joe: So you’ve got broken CSV, or convoluted XML. What a choice! Good thing there’s another option.

Jim: What? What did you find?

Frank: This better not be another innerHTML fiasco...

Joe: I found JSON!

Jim and Frank: JSON? What the heck is that?

Joe: JSON is JavaScript Standard Object Notation. It’s a way to represent a JavaScript ...

Get Head First Ajax now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.