Product Documentation

MQTT V3 Plug-in Reference

Previous Topic

Next Topic

Interpreting Non-JSON Data Types

JSON natively supports six data types: string, number, Boolean, null, object, and array. JSON does not natively support date, time, timestamp (date and time combined), binary data, etc. In JSON documents, it is common to represent these non-native types using native data types, but this practice generally requires the use of external metadata to explain how to interpret the non-native types.

Default Properties

c-tree provides some "default_____Format" properties to define a Persistence Topic’s default behaviors for interpreting values stored in JSON properties. This allows c-tree to properly transform and store them as valid native values in c-tree database tables.

Including any of these properties in a Persistence Topic affects that Persistence Topic only, and not any other Persistence Topics.

"defaultBinaryFormat"

  • String
  • Optional
  • Defaults to "BYTE_ARRAY"
  • Values: "BYTE_ARRAY", "HEX", "BASE64"

It specifies how to interpret JSON properties containing binary values.

There are multiple ways to represent binary values in JSON strings, such as embedding safe ASCII characters in strings using base64 encoding ("SGVsbG8gV29ybGQ=") or hexadecimal encoding ("FF003D"). Binary can also be represented as an array of numbers, such as [0,1,99,100,255]. This property can be used to tell a Persistence Topic how to interpret JSON properties that contain binary values.

"AlterPersistenceTopic" can modify this later.

"defaultNumberFormat"

  • String
  • Optional
  • Defaults to "TRUNCATE"
  • Values: "TRUNCATE", "ROUNDUP", "ROUNDDOWN"

It specifies how to transform JSON floating-point numbers into Integer fields.

A JSON number is generally implemented as an 8-byte double-precision float. If you wish to store that number in an integer field/column, this property can be used to tell a Persistence Topic how to perform the needed conversion.

"AlterPersistenceTopic" can modify this later.

"defaultDateFormat"

  • String
  • Optional
  • Defaults to "MM.DD.CCYY"
  • Values: "MM.DD.CCYY", "MM.DD.YY", "DD.MM.CCYY", and "DD.MM.YY"

It specifies how to interpret JSON strings and numbers as date fields.

Dates are generally represented as strings (such as "12/01/2002") in JSON documents. This property can be used to tell a Persistence Topic how to interpret that string.

If a date is specified in the wrong format, an error such as “Not able to set value [July 4, 1976] to field” is logged to CTSTATUS.FCS and the field is set to null.

The "." character in the format string signifies that any non-numeric character can be used to delimit the parts of the date.

"AlterPersistenceTopic" can modify this later.

"defaultTimeFormat"

  • String
  • Optional
  • Defaults to "hh.mm.am/pm"
  • Values: "hh.mm.am/pm", "hh.mm.ss.am/pm", "hh.mm.ss", 20:15:30, 20.15&30, 20H15M30S, "hh.mm", "hhmm"

It specifies how to interpret JSON strings and numbers as time fields.

Times are generally represented as strings (such as "8:15:30 PM") in JSON documents. This property can be used to tell a Persistence Topic how to interpret that string.

"AlterPersistenceTopic" can modify this later.

TOCIndex