Package oracle.nosql.driver.values

# Class JsonOptions

java.lang.Object
oracle.nosql.driver.values.JsonOptions

public class JsonOptions extends Object
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

  Fields
  Modifier and Type
  Field
  Description
  `static final JsonOptions`
  `PRETTY`
  Static `JsonOptions` instance with default values for all but the pretty-print option, which is set to true.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JsonOptions()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `getAllowComments()`
  Returns whether comments embedded in JSON are allowed on input.
  `boolean`
  `getAllowNonNumericNumbers()`
  Returns whether non-numeric numbers, such as NaN or INF are allowed on input.
  `boolean`
  `getAllowSingleQuotes()`
  Returns whether single quotes are allowed in JSON on input.
  `boolean`
  `getMaintainInsertionOrder()`
  Returns whether parsed JSON will use a Map that maintains insertion order.
  `boolean`
  `getNumericAsNumber()`
  Returns whether numeric values will be mapped to `NumberValue` when parsed from JSON input.
  `boolean`
  `getPrettyPrint()`
  Returns whether JSON will be pretty-printed on output.
  `boolean`
  `getTimestampAsLong()`
  Returns whether `TimestampValue` instances will be mapped to a long representation when output as JSON.
  `boolean`
  `getTimestampAsString()`
  Returns whether `TimestampValue` instances will be mapped to a string representation when output as JSON.
  `JsonOptions`
  `setAllowComments(boolean value)`
  Tells the system to allow C/Java style comments embedded in JSON of the format \/* comment *\/ on input.
  `JsonOptions`
  `setAllowNonNumericNumbers(boolean value)`
  Tells the system to allow non-numeric values as numbers, such as NaN, on JSON input.
  `JsonOptions`
  `setAllowSingleQuotes(boolean value)`
  Tells the system to allow single quotes instead of double quotes in JSON on input.
  `JsonOptions`
  `setMaintainInsertionOrder(boolean value)`
  Tells the system to use a Map that maintains insertion order when parsing JSON.
  `JsonOptions`
  `setNumericAsNumber(boolean value)`
  Tells the JSON parser on input to represent all numeric values as `NumberValue`.
  `JsonOptions`
  `setPrettyPrint(boolean value)`
  Tells the system to pretty print JSON on output.
  `JsonOptions`
  `setTimestampAsLong(boolean value)`
  Tells the system to represent `TimestampValue` instances in a long representation when exported as JSON.
  `JsonOptions`
  `setTimestampAsString(boolean value)`
  Tells the system to represent `TimestampValue` instances in a string representation when exported as JSON.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PRETTY

    public static final JsonOptions PRETTY
    Static `JsonOptions` instance with default values for all but the pretty-print option, which is set to true.

- ## Constructor Details

  - ### JsonOptions

    public JsonOptions()

- ## Method Details

  - ### setNumericAsNumber

    public JsonOptions setNumericAsNumber(boolean value)
    Tells the JSON parser on input to represent all numeric values as `NumberValue`. This can consume extra space but ensures that there is no loss of precision. This option has no effect when representing `FieldValue` 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

    public JsonOptions setTimestampAsString(boolean value)
    Tells the system to represent `TimestampValue` 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

    public JsonOptions setTimestampAsLong(boolean value)
    Tells the system to represent `TimestampValue` 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

    public JsonOptions setPrettyPrint(boolean value)
    Tells the system to pretty print JSON on output.
    Parameters:
      `value` - true or false
    Returns:
      this

  - ### setAllowNonNumericNumbers

    public JsonOptions setAllowNonNumericNumbers(boolean value)
    Tells the system to allow non-numeric values as numbers, such as NaN, on JSON input.
    Parameters:
      `value` - true or false
    Returns:
      this

  - ### setAllowComments

    public JsonOptions setAllowComments(boolean value)
    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

    public JsonOptions setAllowSingleQuotes(boolean value)
    Tells the system to allow single quotes instead of double quotes in JSON on input.
    Parameters:
      `value` - true or false
    Returns:
      this

  - ### setMaintainInsertionOrder

    public JsonOptions setMaintainInsertionOrder(boolean value)
    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 to `NumberValue` when parsed from JSON input.
    Returns:
      true if numerics will be mapped

  - ### getTimestampAsString

    public boolean getTimestampAsString()
    Returns whether `TimestampValue` 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 whether `TimestampValue` 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