4 Working with JSON

This chapter provides examples on working with JSON data. If you want to follow along with the examples, get the Examples download from here and run the SQLJSONExamples script found in the sqlfolder. This creates the table and imports the data used.

JSON data is written to JSON data columns by providing a JSON object. This object can contain any valid JSON data. The input data is parsed and stored internally as Oracle NoSQL Database datatypes:

  • When numbers are encountered, they are converted to integer, long, or double items, depending on the actual value of the number (float items are not used for JSON).

  • Strings in the input text are mapped to string items.

  • Boolean values are mapped to boolean items.

  • JSON nulls are mapped to JSON null items.

  • When an array is encountered in the input text, an array item is created whose type is Array(JSON). This is done unconditionally, no matter what the actual contents of the array might be.

  • When a JSON object is encountered in the input text, a map item is created whose type is Map(JSON), unconditionally.

Note:

There is no JSON equivalent to the TIMESTAMP datatype, so if input text contains a string in the TIMESTAMP format it is simply stored as a string item in the JSON column.

The remainder of this chapter provides an overview to querying JSON data.