datasetjson 0.4.0
JSON handling moved into the package
Reading and writing are now handled by the yyjson C library, bundled with the package, rather than by an R JSON package. The practical effects:
-
Numbers survive a write and read unchanged. Previously a float below roughly 5e-7 was read back as
0, and larger values could lose their final digits. Values are now written at the shortest precision that reads back identically, and parsed to a double in C rather than through R. Files written by earlier versions are unaffected - the loss happened on read, so re-reading them with this version recovers the original values (#97). - Reading is substantially faster - roughly 15-18x on files of a few hundred thousand rows and up, and it scales linearly with file size.
-
yyjsonrandjsonvalidateare no longer required.Importsis now justhms;jsonvalidatemoved toSuggestsand is needed only for thevalidate_*()functions (#70).
New formats
-
read_dataset_ndjson(),write_dataset_ndjson()andvalidate_dataset_ndjson()support the Dataset NDJSON representation, where the dataset metadata forms the first line and each row follows as a JSON array. -
read_dataset_dsjc(),write_dataset_dsjc()andvalidate_dataset_dsjc()support Dataset JSON Compressed (.dsjc), a zLib stream of Dataset NDJSON content. Rows are compressed as they are written, so a large dataset never needs its uncompressed form held in memory (#78). -
datasetjson_example()now shipsdm.json,dm.ndjsonanddm.dsjc.
Behavior changes
-
decimals_as_floatshas been removed fromread_dataset_json(). Columns withdataType = "decimal"andtargetDataType = "decimal"are always converted to numeric on read, as the Dataset JSON v1.1 specification requires (#77). -
digitsis deprecated inwrite_dataset_json()andwrite_dataset_ndjson(). It is ignored, and supplying it warns. Decimals are written at whatever precision reads back as the same value, so there is no precision left for it to control. To render values at a fixed precision, format the column to character yourself and declare it asdecimal/decimalin the column metadata. -
float_as_decimalsis no longer needed to protect precision and setting it now warns to say so. It remains available as an interoperability choice for systems that require thedecimaltype. - Reading a file whose columns lack a
name, or whoserecordsvalue is missing, now reports the problem rather than failing obscurely or silently substituting a value.
Fixes
-
read_dataset_json()setsformat.sasfrom thedisplayFormatcolumn attribute (#87). - Reading from a URL returned only the first line of the file, so any pretty-printed JSON lost everything after it and NDJSON returned no rows.
-
write_dataset_json()withfloat_as_decimals = TRUEwroteNAas a padded string rather than JSONnull(#76). -
extract_xpt_meta()in theconverting_filesvignette could return-Inffor thelengthof an empty or all-NAstring column; the minimum is now 1 (#71).
datasetjson 0.3.0
CRAN release: 2025-01-30
This release provides a significant overhaul of the package due to the updates for Dataset JSON 1.1.0. Performance has also been significantly improved, as well as the main object interface.
- Initial support for Dataset JSON v1.1.0 schema
- Flip JSON backend to {yyjsonr} (#32)
- Redesign of core objects
- New vignettes and helper functions