Wildcard Data Types

The Oracle NoSQL Database data model includes the following wildcard data types:

Table 2-4 Wildcard Data Types

Data Type Description Examples
ANY Any instance of any NoSQL type is an instance of the ANY type as well.

{ "city" : "Santa Cruz", "zip" : 95008, "phones" : [ { "area" : 408, "number" : 4538955, "kind" : "work" }, { "area" : 831, "number" : 7533341, "kind" : "home" } ] }

"Santa Cruz"

95008

TRUE

'0x34 0xF5'

'2020-01-20T12:15:054'

[ 12, "foo", { "city":"Santa Cruz"}, [2, 3]]

ANYATOMIC Any instance of any other atomic type is an instance of the ANYATOMIC type as well. The json null value is also an instance of ANYATOMIC.

"Santa Cruz"

95008

TRUE

'0x34 0xF5'

'2020-01-20T12:15:054'

ANYJSONATOMIC Any instance of a numeric type, the string type, and the boolean type is an instance of the ANYJSONATOMIC type as well. The json null value is also an instance of ANYJSONATOMIC.

"Santa Cruz"

95008

true

JSON The JSON type represents all valid json values. Specifically, an instance of JSON can be
  1. an instance of ANYJSONATOMIC,
  2. or an array whose elements are all instances of JSON,
  3. or a map whose field values are all instances of JSON.

{ "city" : "Santa Cruz", "zip" : 95008, "phones" : [ { "area" : 408, "number" : 4538955, "kind" : "work" }, { "area" : 831, "number" : 7533341, "kind" : "home" } ] }

"Santa Cruz"

95008

true

[ 12, "foo", { "city":"Santa Cruz"}, [2, 3]]

ANYRECORD Any instance of any other RECORD type is an instance of the ANYRECORD type as well. { "city" : "Santa Cruz", "zip" : 95008 }

A data type is called precise if it is not one of the wildcard types and, in case of complex types, all of its constituent types are also precise. Items that have precise types are said to be strongly typed.

Wildcard types are abstract, which means that no item can have a wildcard type as its type. However, items may have an imprecise type. For example, an item may have MAP(JSON) as its type, indicating that its value is a map that can store field values of different types, as long as all of these values belong to the JSON type. In fact, MAP(JSON) is the type that represents all json objects (json documents), and ARRAY(JSON) is the type that represents all json arrays.

To load json data into a table, Oracle NoSQL Database offers programmatic APIs that accept input json as strings or streams containing json text. Oracle NoSQL Database will parse the input text internally and map its constituent pieces to the values and types of the data model described here. Specifically, when an array is encountered in the input text, an array item is created whose type is ARRAY(JSON). When a JSON object is encountered in the input text, a map item is created whose type is MAP(JSON). When numbers are encountered, they are converted to integer, long, double, or number items, depending on the actual value of the number. Finally, strings in the input text are mapped to string items, boolean values are mapped to boolean items, and JSON nulls to json null items. In general, the end result of this parsing is a tree of maps, arrays, and atomic values. For persistent storage, the tree is serialized into a binary format.

JSON data is schemaless, in the sense that a field of type JSON can have very different kind of values in different table rows. For example, if "info" is a top-level table column of type JSON, in one row the value of "info" may be an integer, in another row an array containing a mix of doubles and strings, and in a third row a map containing a mix of other maps, arrays, and atomic values. Furthermore, the data stored in a JSON column or field, can be updated in any way that produces a still valid JSON instance. As a result, each JSON tree (either in main memory or as a serialized byte array on disk) is selfdescribing with regard to its contents.