On the JSON website (http://www.json.org), JSON is described as:
Numbers 1 and 3 are certainly true. Number 2 depends on the type of human. Experienced programmers will find that they can get comfortable with the syntax relatively quickly.
The process for sending data between the browser and server with JSON is as follows:
The examples below show how to transfer data to the server using JSON.
The server-side end of this process is the ReceiveJSON response route in server.js. In response to a POST request, it responds with either "And hi there to you!" (if the request parameter strJSON's msg field has value "Hi There!") or "Later Gator!" (if the msg field has any other value).
This code is relatively simple. The client-side script:
The server-side script:
Another oft-touted advantage of JSON is that it is lightweight. Compare, for example, the rockbands object we saw earlier in the lesson in JSON vs. XML:
The XML representation has almost twice as many characters. While for long files, this may be significant, in most cases this will not cause any noticeable difference. Further, if you were to represent the XML with attributes rather than elements, the difference would be much less.
The biggest disadvantage of working with JSON is it is yet another syntax we need to familiarize ourselves with. However, with a little effort, most developers will find it's not too difficult to get comfortable with.