Page 303 -
P. 303
mobile app development
JSON Exposed
This week’s interview:
The Data Interchange Lowdown
Head First: Hello, JSON. Thanks for agreeing to Python, use JSON to convert it to JSON’s object
talk to us today. notation, and then send the converted data to
another computer running a program written in C#?
JSON: No problem. Always willing to play my part
in whatever way I can. JSON: And as long as C# has a JSON library, you
can recreate the Python data as C# data. Neat, eh?
Head First: And what is that, exactly?
Head First: Yes, that sounds interesting…only
JSON: Oh, I’m just one of the most widely used [winks] why would anyone in their right mind want
data interchange formats on the Web. When you to program in C#?
need to transfer data over the Internet, you can rely
on me. And, of course, you’ll find me everywhere. JSON: [laughs] Oh, come on now: be nice. There’s
plenty of reasons to use different programming
Head First: Why’s that?
languages for different reasons.
JSON: Well…it’s really to do with my name. The Head First: Which goes some of the way to explain
“JS” in JSON stands for “JavaScript” and the “ON” why we have so many great programming titles, like
stands for “Object Notation.” See?
Head First C#, Head First Java, Head First PHP and
Head First: Uh…I’m not quite with you. MySQL, Head First Rails, and Head First JavaScript.
JSON: I’m JavaScript’s object notation, which JSON: Was that a shameless, self-serving plug?
means I’m everywhere.
Head First: You know something…I think it might
Head First: Sorry, but you’ve completely lost me. well have been! [laughs].
JSON: The first two letters are the key ones: I’m JSON: [laughs] Yes, it pays to advertise.
a JavaScript standard, which means you’ll find me Head First: And to share data, right?
everywhere JavaScript is…which means I’m in every
major web browser on the planet. JSON: Yes! And that’s exactly my point: when you
need a language-neutral data interchange format that is
Head First: What’s that got to do with Python?
easy to work with, it’s hard to pass me by.
JSON: That’s where the other two letters come Head First: But how can you be “language neutral”
into play. Because I was initially designed to allow when you have JavaScript in your name?
JavaScript data objects to be transferred from one
JavaScript program to another, I’ve been extended JSON: Oh, that’s just my name. It’s what they
to allow objects to be transferred regardless of what called me when the only language I supported was
programming language is used to create the data. JavaScript, and it kinda stuck.
By using the JSON library provided by your favorite Head First: So they should really call you
programming language, you can create data that something else, then?
is interchangeable. If you can read a JSON data
stream, you can recreate data as you see fit. JSON: Yes, but “WorksWithEveryProgramming
LanguageUnderTheSunIncludingPythonObject
Head First: So I could take an object in, say,
Notation” doesn’t have quite the same ring to it!
you are here 4 267