Here is a simple JSON object
{name:'Dilan'}
There is another way to write this
{'name':'Dilan'}
Both are same. Then how do we use JSON in javascript? Answer is pretty simple... here it is..
var person={'name':'Dilan'};
alert(person.name);
Done! That is it. Wait a sec how about if a person have many interests.. that needed to be represented in an array.. ok! here we go
var person = {'name':'Dilan', 'interests':['watch movies','play crickets','code']}
who la! We are done! So this should be a good foundation for you to start! Next time when your fellow developer or interview board ask for a JSON don't freak out! Just hit them back with a good example! cheers!!!
1 comment:
The part where I freak out would be JavaScript not JSON :) because JSON feels (and considered) much like YAML
Post a Comment