Introduction to JSON – JavaScript Object Notation

JSON – JavaScript Object Notation

What is JSON?

JSON is way to describe data so it is easy to use with JavaScript and Javascripting can be easily interpreted.

If you use RSS or XML Feeds, you find that JSON is much easier to parse than XML, but little bit harder to read specially when minified.

JSON data is nothing more than text in a specific format and when it all come bunch together it is tough to read.

Lots of different companies like Facebook, Google provide access to their data in JSON format. Also JavaScript SDK relies heavily on JSON.

Basic JSON Object:

JSON data is a JSON Object.

JSON Object is simply text wrapped in curly braces. Inside this they have string usually a variable names and values separated by colon. You can specify more than one element in the object by separating them with commas.

JSON string (on the left of object):

String on the left is a variable name but it is more like standard C string. If you need to escape a character, you can use a backslash. If you need to escape character you can use backslash.

JSON sting value (on the right of object):

Value under right of the object can be lot of different things. That includes strings, numbers, and other nesting objects or even an array which in-turn can also have other objects.

Example of JSON data:

You can see an object with string called ‘users’.
Then you see semi colon and array with bunch of other objects. Other objects are in curly braces. Notice above example, ‘joined’ is also another object with bunch of data in it. So now you get an idea how you can put objects inside of other objects.

Although JSON works well with JavaScript, there are number of PHP functions that can easily parse JSON data. JSON has some security features that may prevent you from loading files from external urls without permission.

JSON is a wonderful tool for JavaScript when you format data in this manner it will be parsed and it will be easier to use in your project.

This entry was posted in Web Application Development and tagged , . Bookmark the permalink.

Comments are closed.