Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector with 1 element should stay a vector when writing to .json (and not become a string) #272

Open
sannegovaert opened this issue Nov 21, 2024 · 0 comments

Comments

@sannegovaert
Copy link
Contributor

When there is 1 reference, this should look like this in datapackage.json:

"references": ["my_reference"]

However, that is not the case when writing a Data Package.

library(camtrapdp)
x <- example_dataset()
x$references <- c("my_reference")
write_camtrapdp(x, directory = "references_as_string")

In datapackage.json, references then looks like this:
"references": "my_reference"

The IPT does not recognize this, as the square brackets are missing.
It does work when a second (empty element) is added:

x$references <- c("my_reference", "")
write_camtrapdp(x, directory = "references_as_vector")

In datapackage.json, references then looks like this:
"references": ["my_reference", ""]
The IPT can handle this, but it genereates an empty field for reference.

unlink("references_as_string", recursive = TRUE)
unlink("references_as_vector", recursive = TRUE)

Created on 2024-11-21 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant