认识JSON
What is JSON?
Why does JSON matter?
How do we use JSON in a project?
We'll also use our newfound skills with JSON at the end ofthis project to build a quick app that loads photos from Flickr withoutrequiring a page refresh.
What Is JSON?
JSONis short for JavaScript Object Notation, and is a way to store information inan organized, easy-to-access manner.In a nutshell, it gives us ahuman-readable collection of data that we can access in a really logicalmanner.
Why Does JSON Matter?
With the rise of AJAX-powered sites, it'sbecoming more and more important for sites to be able to load data quickly and asynchronously,or in the background without delaying page rendering. Switching up the contentsof a certain element within our layouts without requiring a page refresh adds a"wow" factor to our applications, not to mention the addedconvenience for our users. Because of the popularity and ease of social media,many sites rely on the content provided by sites such as Twitter, Flickr, andothers. These sites provide RSS feeds, which are easy to import and use on theserver-side, but if we try to load them with AJAX, we run into a wall: we canonly load an RSS feed if we're requesting it from the same domain it's hostedon.
JSON allows us to overcome the cross-domain issue because wecan use a method called JSONPthat uses a callback function to send the JSON data back to our domain. It'sthis capability that makes JSON so incredibly useful, as it opens up a lot ofdoors that were previously difficult to work around.
http://www.copterlabs.com/json-what-it-is-how-it-works-how-to-use-it/
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。