Pages

Monday, May 4, 2015

JSON array example

JSON Array


first of all, what is JSON exactly?  have you heard JSON everywhere? JSON JSON JSON JSON. 
What the f*ck is JSON?


JSON = Javascript Object Notation.  It was called like that because javascript was the first programming language that take an advantage of the format. So what do can we do with JSON?


mainly JSON is used for primarily data transfer, kind of like XML (but not contain tag, readable, and less size). JSON didn't looked like html / css which have an interface/graphic showed to user. JSON must keep it's size small so it contain only important data ( String, Double,Float, Integer, Array,Boolean, Object,Null ). 

JSON also can be used to connect front end application with backend application ( retreiving data ) without a page reload ( which is commonly achievable using javascript with  AJAX request ).


JSON syntax  =     {}

JSON example =  {"name":"toro", "nationality":"indonesia", "hobby":"programming"}

JSON array example  = {"other_hobby": ["swimming","basketball","dota2"]}


very simple right?

also JSON can use line break because it didn't bothered with white space. so we can use line break to break the line code so it is very clear and readable like this:



JSON example with white space :


{
"name" : "toro" ,
"nationality" : "indonesia",
"hobby" : "programming"
}


JSON array example with white space :



{
 "other_hobby" : ["swimming","basketball","dota2"],
 "another_hobby_again" : ["sleeping","rafting", "reading"]
}



json string =  using " "
json integer, double float =  not use " "
json boolean = without " "  , true | false    
json null = without " " , null
json object = {}     -> can contain anything. same as json syntax itself





No comments:

Post a Comment