Writes a data frame to a CDISC Dataset-JSON v1.1 file following the
official CDISC specification. Column labels, types, and lengths are
extracted from attributes set by set_label(),
set_length(), or apply_spec().
If the herald.sort_keys attribute is set (e.g., by
apply_spec() or sort_keys()), the data is sorted
before writing. JSON is always UTF-8.
Usage
write_json(
x,
file,
dataset = NULL,
label = NULL,
study_oid = "",
metadata_version_oid = "",
metadata_ref = NULL,
originator = "herald"
)Arguments
- x
A data frame.
- file
Output file path (should end in
.json).- dataset
Dataset name (e.g.,
"DM"). Default: inferred from the"dataset_name"attribute or the file name.- label
Dataset label. Default: from the
"label"attribute.- study_oid
Study OID for metadata. Default:
"".- metadata_version_oid
Metadata version OID. Default:
"".- metadata_ref
Path to define.xml. Default:
NULL.- originator
Originator name. Default:
"herald".
See also
read_json() for reading, write_xpt() for XPT I/O,
apply_spec() to decorate before writing.
Other io:
json_to_xpt(),
read_json(),
xpt_to_json()
