Reading and Writing Data Overview

Reading and Writing data using JavaScript Object Notation (JSON)

Overview

JavaScript Object Notation (JSON) is a human-readable way to format data and is commonly used for transmission between a server and web applications. JavaScript Object Notation (JSON) is a more “lightweight” and understandable format than another commonly used alternative known as Extensible Markup Language (XML). Because of these advantages and the fact that it is understood natively by the JavaScript programming language used in browsers, it is generally the preferred format today.

JavaScript Object Notation (JSON) objects are a set of unordered key-value pairs, separated by a colon (“:“) and encapsulated with curly brackets (“{“ “}”), also called braces. The key portion of the pair is a name in double quotes and the value can be a text, integer, number, boolean or array value. Each of the pairs is separated by a comma (“,”) and any whitespace is ignored.

In the following example, the first key name is “firstName” with a text value of “Joe”, the second key name is “lastName” with a text value of “Smith”, the third key name is “age” with an integer value of 15, and the fourth key name is “student” with a boolean value of true.

Example JavaScript Object Notation format:

{
     "firstName" : "Joe",
     "lastName" : "Smith",
     "age" : 15,
     "student" : true
}

JSON in Quorum

In order to access the JavaScriptObjectNotation class we must add the “use Libraries.Data.Formats.JavaScriptObjectNotation” statement at the beginning of our class definitions when working with JavaScript Object Notation (JSON).

Next Tutorial

In the next tutorial, we will discuss JavaScript Object Notation Using Primitives, which describes an introduction to creating JavaScriptObjectNotation objects with primitive value types..