Showing posts with label JSON. Show all posts
Showing posts with label JSON. Show all posts

JSON in Java


Download the zip from here.

Here is a snippet code how to use it:

JSON

JSON solves 2 problems:

1. It's a text, so it's very easy for network transmission. -- faster.

  • get JSON Data String from server: request.reponseText

2. It could also be easily converted into an object, which is very convenient for data manipulation. --convenient.

  • var itemDeatils = eval( '(' + JSON_DATA_STRING + ')'); //JavaScript's build-in function eval() could easily turn JSON Data String that you got from server into an object.
  • now you could use dot notaion on "itemDetails" now.

JSON

Java Standard Object Notion

It's a format, like XML.

go to http://json.org find all the information.
All the libraries for different languages.

json2.js is JSON parser library for JavaScript.
JSON.parse("blabla");
vs
eval('(' + "blabla" + ')');

JSON is safer and faster.

Tell me again why we want to use JSON.parse() instead of eval()?

Understand JSON.parse() eventually will use eval(), but before that, it will do some checking for you, so it's safer.

Here is a link for details.