8/29/09

Combination Trap JSON and HTML

We direct would the application of JSON in coding, for the purpose is better if you has mastered basiss HTML/JavaScript, which it is of course will water down understanding process.

To be more recognizes how JSON to explain a data, following is example of writing of JSON in a ? le HTML:

< html>

< head>

< /head>

< body>

< script>

// JSON

var myObject = {“ product”: {

“ fruit”:[

{“ name”: “ banana”,

“ price”: 1000

},
{“ name”: “ apple”,

“ price”: 7000

}],
“ ATK”:[

{“ name”: “ pulpen”,

“ price”: 500

},
{“ name”: “ ruler”,

“ price”: 100

}]
}};
document.writeln(myObject.produk.buah[1].nama); // its(the output is apple

document.writeln(myObject.produk.buah[1].harga); // its(the output is 7000

< /script>

< /body>

< /html>

Example above declaration of data with JSON. Seen like a data structure that is enough easy to be understood, not?

To access and presents it, you can apply comand JavaScript documentwriteln like the one is written also at above program code.

Sees way of writing of JSON, Anda of course will tolerate why JSON is abbreviations from JavaScript Object Notation, because JSON of course bases on JavaScript.

Data type in JSON can be categorized as beri-kut:

1. Number ( in the form of integer, real, or ? oating point).

2. String.

3. Boolean ( true and false).

4. Array.

5. Object.

6. null.