This function takes a list with person and time data and saves it into JSON bds format (which can be sent to JAMES).
write_bds(
x = NULL,
auto_format = TRUE,
format = "3.0",
schema = NULL,
file = NULL,
organisation = 0L,
indent = NULL,
check = TRUE,
verbose = FALSE,
...
)List containing elements psn (persondata) and xyz
(timedata) with data of the target child. See bdsreader:::init_bdsreader()
for supported fields.
Logical. Should a field Format be written to the
result? Default is TRUE. Note: Only used for versions 1.0 and 1.1.
String. JSON data schema version number. There are currently
three schemas supported: "1.0", "1.1", "2.0", "3.0" and "3.1".
Formats "1.0" and "1.1" are included for backward compatibility only.
Use format = "3.1" for new applications.
A file name (optionally including the path) with the JSON
validation schema.
The schema argument overrides format. The function extracts the
version number for the basename, and overwrites the
format argument by version number.
File name. The default (NULL) returns the json
representation of the data and does not write to a file.
Integer. Organisation number of the caller. Optional.
Integer. Number of spaces to indent when using
jsonlite::prettify(). When not specified, the function writes
minified json.
Logical. Should function check json to conform to schema?
Logical. Print file message?
Passed down to jsonlite::toJSON().
A string with bds-formatted JSON codes, or NULL for invalid
JSON
Functions read_bds() and write_bds() are inverse operations.
If the date of birth is not known, the conversion uses the
artificial birth date 01 Jan 2000 to calculate measurement
dates from age.
fn <- system.file("extdata/bds_v1.0/smocc/Laura_S.json",
package = "jamesdemodata")
tgt <- read_bds(fn, format = "1.0", append_ddi = FALSE)
js1 <- write_bds(tgt, format = "1.0")
js2 <- write_bds(tgt, format = "2.0")
js3 <- write_bds(tgt)