Save an ipums_extract to a JSON-formatted file. For an overview of ipumsr microdata API functionality, see vignette("ipums-api", package = "ipumsr").

save_extract_as_json(extract, file)

Arguments

extract

An ipums_extract object.

file

File path at which to write the JSON-formatted extract definition.

Value

The file path where the extract definition was written, invisibly.

Details

Note that this function only saves out the properties of an extract that are required to submit a new extract request, namely, the description, data structure, data format, samples, variables, and collection.

Examples

my_extract <- define_extract_usa("Example", "us2013a", "YEAR")

extract_json_path <- file.path(tempdir(), "usa_extract.json")
save_extract_as_json(my_extract, file = extract_json_path)

copy_of_my_extract <- define_extract_from_json(extract_json_path)

identical(my_extract, copy_of_my_extract)
#> [1] TRUE