Engineering Full Stack Apps with Java and JavaScript
JSON stands for JavaScript Object Notation. JSON is an open standard format that transmits data using human-readable text in the form of attribute–value pairs. Although originally derived from the JavaScript scripting language, JSON is a language-independent data format, and code for parsing and generating JSON data is readily available in a large variety of programming languages including Java.
JSON is currently described by two competing standards, RFC 7159 and ECMA-404. The official Internet media type for JSON is application/json. If this MIME type header is not sent across the browser, it treats the incoming JSON as plain text. The JSON filename extension is .json.
JSON is basically built on two structures:
All modern programming languages like Java support them in one form or another.
JSON syntax for different types of data structures like object, array, and values are as follows:
Example
{
"name": "Heartin",
"age":29,
"skill": ["java", "javaee"]
}
JSON can be considered a subset of the object literal notation of JavaScript and a JSON object can be created similar to how we create a JavaScript object using curly braces:
<script type="text/javascript">
var emp = {
"name": "Heartin",
"age":29,
"skill": ["java", "javaee"]
};
</script>
Few notable differences from a normal JavaScript object are:
There are many JSON libraries available in java and the most popular seems to be Jackson and Google GSon. Understanding the importance of JSON, Java EE has also included support for JSON through its APIs in Java EE 7.
Java EE 7 provides two types of JSON APIs: a streaming event based API and object model API. The streaming event based API (JsonParser) is based on Stax and is useful for large JSON documents. The object model API (JsonObject) is DOM based and stores everything in memory, and is useful when you have to navigate between different nodes of the JSON document.
Java EE 7 also provides support for HTML 5 WebSockets which can be used effectively to transfer JSON data between client and server bidirectional.
http://en.wikipedia.org/wiki/JSON
Developing RESTful Services with JAX-RS 2.0,WebSockets, and JSON by Masoud Kalali and Bhakti Mehta.