Skip to contents

Serializes a provenance object to JSON format, optionally writing to a file.

Usage

provenance_to_json(prov, path = NULL)

Arguments

prov

A metasurvey_provenance list.

path

File path to write JSON. If NULL, returns the JSON string.

Value

JSON string (invisibly if path is provided).

Examples

svy <- Survey$new(
  data = data.table::data.table(id = 1:5, w = rep(1, 5)),
  edition = "2023", type = "test",
  engine = "data.table", weight = add_weight(annual = "w")
)
prov <- provenance(svy)
provenance_to_json(prov)
#> {
#>   "source": {
#>     "path": null,
#>     "timestamp": "2026-02-25T12:01:00",
#>     "initial_n": 5,
#>     "hash": null
#>   },
#>   "steps": [],
#>   "environment": {
#>     "metasurvey_version": "0.0.21",
#>     "r_version": "4.5.2",
#>     "survey_version": "4.5"
#>   }
#> }