Have you ever heard about JSON? I’m almost sure you have.
JSON (JavaScript Object Notation) is an easy to handle and understand data format used everywhere.
As its name says, it’s based on the way that JavaScript can handle objects, like this:
var myCar = {
color: 'red',
doors: 5,
wheels: 4
};
It’s easy to understand, isn’t it? I have a red car, that have five doors and four wheels.
Now imagine some data got from a database in this format. It would look like this:
var users = [
{ name: 'E. Myller', genre: 'male' },
{ name: 'Voziv', genre: 'male' },
{ name: 'K. Hellen', genre: 'female' },
{ name: 'Elomar', genre: 'male' }
];
It’s also easy to understand, right? We have four users: E. Myller, Voziv, K. Hellen and Elomar.
“Ok, uncle eMyller. It’s pretty beautiful and clean. Any other reason that would make me use it from now on?”
Yes. The usage. Now you can, for example, handle that data got from a database as a simple JS object. Take this example, using the previous code:
var user; while (user = users.shift()) {
alert(user.name);
}
Easy to understand: it loops through the users and shows the name of each of them.
Many languages today have native support for it. At web, it’s even more useful because we can join some JSON data with Ajax requests and get awesome results easily.
Use your creativity and do things quickly and easily with JSON!


