How are grid field values and checkbox values retrieved from the API in EDC/CDMS?
Table of Contents
Grids
Grid field values are stored as so-called JSON objects. A JSON object looks like this:
{"0":{"0":"A","1":"C"},"1":{"0":"B","1":"D"}}
In this case, the grid field consists of 2 rows, numbered 0 and 1 (outside the inner brackets), and two columns, also numbered 0 and 1 (inside the inner brackets). For the case above, the grid would look like this in Castor:
See also our article on calculating with grids.
This is because a grid is seen as one field, and all values of the grid cells need to be saved within that one field. Since the API retrieves the 'raw' data directly from the database, grid values will be retrieved in JSON format as well. It is possible to convert a JSON object into a dataframe in R with the jsonlite package.
Checkboxes
For checkbox fields all option values that are checked are saved in the field value, separated by a semicolon. For example, see the field below.
The option group of the field looks like this:
Since the first two options with the values 1 and 2 are selected, the field value is saved as, and will be retrieved from the API like this:
0;1