skip to main content
Welcome to the Progress DataDirect Autonomous REST Connector for JDBC : Mapping objects to tables : Normalizing JSON maps
  

Try DataDirect Drivers Now

Normalizing JSON maps

A JSON map is a collection of key-value pairs that contain a set of unique keys. Typically, the keys are used for reference and, therefore, act as identifiers with a real world relationship, such as ID numbers, dates, or times. The driver will attempt to detect maps by recognizing patterns and formats in the keys when sampling an endpoint. For the driver to automatically recognize an object as a map, the object must have the following characteristics:
*The keys must me be one of the following types:
*Numeric values
*GUIDs
*Dates formatted as YYYY-MM-DD
*Times using the ISO 8061 format. The map may contain values with and without timezones in the same map.
*Timestamps using the ISO 8061 format. The map may contain values with and without timezones in the same map.
*Every key in the object must be of the same type.
For example, the following JSON document contains a map that uses dates as keys:
{
"1979-10-31":{"attendance":"12080","opponent":"Wildcats","result":"loss"},
"1979-11-06":{"attendance":"34000","opponent":"Mustangs","result":"loss"},
"1979-11-06":{"attendance":"8500","opponent":"Jets","result":"loss"},
}
The driver normalizes the key-value pairs in the JSON map to a child table. The fields in the map value are mapped into relational columns. For example, the attendance and opponent fields, are mapped to relational columns of the same name. The primary key is determined by the key portion of the key-value pair and maps to the KEY column by default.
You can specify the name of the parent table using the Table property. If no value is specified, The name is derived from the endpoint from which the data was sampled. The parent table for our example is named SEASON_RESULTS and takes the following form:
Table 4. SEASON_RESULTS
KEY (PK)
ATTENDANCE
OPPONENT
RESULT
1979-10-31
12080
Wildcats
loss
1979-11-06
34000
Mustangs
loss
1979-11-06
8500
Jets
loss