Posts Tagged ‘data format’

What an amazing illusion we humans have created

May 19, 2016

What an amazing illusion we humans have created. We’ve created the illusion that the computer is filled with text and text has lines. The illusion is so complete, so compelling, that we have an incredibly hard time thinking there could be anything other than text inside our computers. And we’ve build a whole tower of stuff on top of the illusion: text editors, text data formats, text programming languages, social media, and so forth.

But in fact, there is no text in the computer, just numbers. And there are no lines. The numbers inside the computer are interpreted by clever software to represent letters and those letters are displayed on a monitor. Certain numbers are interpreted to represent an end-of-line marker, the succeeding numbers (er, letters) are displayed on the next line of the monitor.

The power of abstraction – amazing!

Why JSON is Important to You!

April 5, 2008

WHAT IS JSON?

JSON stands for JavaScript Object Notation. (JSON is pronounced like the name Jason)

It is a data format. (XML is also a data format)

The JSON data format is ideally suited for consumption by a JavaScript program. (In fact, JSON is JavaScript!)

WHY SHOULD I CARE ABOUT JAVASCRIPT?

Because Ajax applications use JavaScript. (And because JavaScript is very cool)

BUT AJAX APPLICATIONS CAN PROCESS DATA FORMATTED AS XML, SO WHY BOTHER WITH JSON?

If the data is formatted as XML then Ajax is limited to fetching data from the same domain (website) that the Ajax application came from.

If the data is formatted as JSON then Ajax can travel across domains. That is, Ajax can access data from anywhere. Think of the power of this: a single Ajax application, running in your browser, can reach out and grab data from an unlimited number of web services, and present it in your browser in a coherent fashion. Awesome!

WHAT DOES JSON LOOK LIKE?

Here’s information about a person, his website, and his email, all structured as JSON:

{“person”: {
“name”: “John Doe”,
“website”: “http://www.example.com/”,
“email”: “jdoe@example.com”
}
}

HOW IS THE DATA IN JSON EXTRACTED?

Very easy: (suppose the variable “data” holds the above JSON data)

data.person.name returns “John Doe”
data.person.website returns http://www.example.com
data.person.email returns jdoe@example.com

ARE THERE WEB SERVICES THAT SERVE UP JSON?

Yes. For example, all of Yahoo’s Web Services can return JSON if it’s requested. Here’s an example:

http://api.search.yahoo.com/NewsSearchService/V1/newsSearch?appid=xyz&query=Obama&output=json

SHOULD MY WEB SERVICE SERVE UP JSON?

I think that it would be good for your web service to be capable of serving up both XML and JSON. You might implement it in the same way Yahoo does, e.g.

http://www.example.com/web-service?output=json

http://www.example.com/web-service?output=xml

WHO DISCOVERED JSON?

JSON is the brainchild of Douglas Crockford, one of the preeminent JavaScript coders in the world today (http://www.crockford.com).

WHERE CAN I GET MORE INFO?

See the excellent book: Bulletproof Ajax, by Jeremy Keith, p. 77-87