Package oracle.nosql.driver.values
Class JsonOptions
java.lang.Object
oracle.nosql.driver.values.JsonOptions
JsonOptions allows applications to configure how JSON is parsed on input
and generated on output. An instance of this class can be associated with
methods that produce and consume JSON to control mappings between JSON and
the types in the Oracle NoSQL Database.
All of the fields in this object are boolean and therefore default to false.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final JsonOptions
StaticJsonOptions
instance with default values for all but the pretty-print option, which is set to true. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether comments embedded in JSON are allowed on input.boolean
Returns whether non-numeric numbers, such as NaN or INF are allowed on input.boolean
Returns whether single quotes are allowed in JSON on input.boolean
Returns whether parsed JSON will use a Map that maintains insertion order.boolean
Returns whether numeric values will be mapped toNumberValue
when parsed from JSON input.boolean
Returns whether JSON will be pretty-printed on output.boolean
Returns whetherTimestampValue
instances will be mapped to a long representation when output as JSON.boolean
Returns whetherTimestampValue
instances will be mapped to a string representation when output as JSON.setAllowComments
(boolean value) Tells the system to allow C/Java style comments embedded in JSON of the format \/* comment *\/ on input.setAllowNonNumericNumbers
(boolean value) Tells the system to allow non-numeric values as numbers, such as NaN, on JSON input.setAllowSingleQuotes
(boolean value) Tells the system to allow single quotes instead of double quotes in JSON on input.setMaintainInsertionOrder
(boolean value) Tells the system to use a Map that maintains insertion order when parsing JSON.setNumericAsNumber
(boolean value) Tells the JSON parser on input to represent all numeric values asNumberValue
.setPrettyPrint
(boolean value) Tells the system to pretty print JSON on output.setTimestampAsLong
(boolean value) Tells the system to representTimestampValue
instances in a long representation when exported as JSON.setTimestampAsString
(boolean value) Tells the system to representTimestampValue
instances in a string representation when exported as JSON.
-
Field Details
-
PRETTY
StaticJsonOptions
instance with default values for all but the pretty-print option, which is set to true.
-
-
Constructor Details
-
JsonOptions
public JsonOptions()
-
-
Method Details
-
setNumericAsNumber
Tells the JSON parser on input to represent all numeric values asNumberValue
. This can consume extra space but ensures that there is no loss of precision. This option has no effect when representingFieldValue
instances as JSON on output.If the resulting object is later inserted into a table it must still match the schema for the table. If the value cannot be cast to the expected type without loss of precision an exception will be thrown on insert.
- Parameters:
value
- true or false- Returns:
- this
-
setTimestampAsString
Tells the system to representTimestampValue
instances in a string representation when exported as JSON. This option has no effect on JSON when used as input. The string format on output conforms to ISO 8601.- Parameters:
value
- true or false- Returns:
- this
-
setTimestampAsLong
Tells the system to representTimestampValue
instances in a long representation when exported as JSON. This option has no effect on JSON when used as input. The format is the number of milliseconds since the Epoch, 1970-01-01T00:00:00.- Parameters:
value
- true or false- Returns:
- this
-
setPrettyPrint
Tells the system to pretty print JSON on output.- Parameters:
value
- true or false- Returns:
- this
-
setAllowNonNumericNumbers
Tells the system to allow non-numeric values as numbers, such as NaN, on JSON input.- Parameters:
value
- true or false- Returns:
- this
-
setAllowComments
Tells the system to allow C/Java style comments embedded in JSON of the format \/* comment *\/ on input. Comments will not be maintained by the system and are stripped on input.- Parameters:
value
- true or false- Returns:
- this
-
setAllowSingleQuotes
Tells the system to allow single quotes instead of double quotes in JSON on input.- Parameters:
value
- true or false- Returns:
- this
-
setMaintainInsertionOrder
Tells the system to use a Map that maintains insertion order when parsing JSON.- Parameters:
value
- true or false- Returns:
- this
-
getNumericAsNumber
public boolean getNumericAsNumber()Returns whether numeric values will be mapped toNumberValue
when parsed from JSON input.- Returns:
- true if numerics will be mapped
-
getTimestampAsString
public boolean getTimestampAsString()Returns whetherTimestampValue
instances will be mapped to a string representation when output as JSON.- Returns:
- true if a string format is used
-
getTimestampAsLong
public boolean getTimestampAsLong()Returns whetherTimestampValue
instances will be mapped to a long representation when output as JSON.- Returns:
- true if a long format is used
-
getPrettyPrint
public boolean getPrettyPrint()Returns whether JSON will be pretty-printed on output.- Returns:
- true if pretty printing is set
-
getAllowNonNumericNumbers
public boolean getAllowNonNumericNumbers()Returns whether non-numeric numbers, such as NaN or INF are allowed on input.- Returns:
- true if non-numeric numbers are allowed.
-
getAllowComments
public boolean getAllowComments()Returns whether comments embedded in JSON are allowed on input.- Returns:
- true if comments are allowed.
-
getAllowSingleQuotes
public boolean getAllowSingleQuotes()Returns whether single quotes are allowed in JSON on input.- Returns:
- true if single quotes are allowed.
-
getMaintainInsertionOrder
public boolean getMaintainInsertionOrder()Returns whether parsed JSON will use a Map that maintains insertion order.- Returns:
- true if maintaining insertion order
-