Skip to content

Commit

Permalink
fix: unboxed elements of taxons when converting to JSON, closes #72
Browse files Browse the repository at this point in the history
  • Loading branch information
brycefrank committed Oct 5, 2024
1 parent 7551753 commit b52ad03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/json.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ taxa_to_json <- function(taxa) {
)
}

out
unbox_nested(out)
}

#' Convert descriptors to JSON
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-json.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ test_that("taxa_to_json returns correct value", {

parsed <- taxa_to_json(taxa)

expect_equal(parsed[[1]][["family"]], "Pinaceae")
expect_equal(parsed[[1]][["genus"]], "Pinus")
expect_equal(parsed[[1]][["species"]], "ponderosa")
expect_equal(parsed[[1]][["family"]], jsonlite::unbox("Pinaceae"))
expect_equal(parsed[[1]][["genus"]], jsonlite::unbox("Pinus"))
expect_equal(parsed[[1]][["species"]], jsonlite::unbox("ponderosa"))
})

test_that("descriptors_to_json returns correct value", {
Expand All @@ -107,8 +107,8 @@ test_that("descriptors_to_json returns correct value", {
parsed_taxa <- descriptors_to_json(descriptors_with_taxa)["taxa"]

expect_equal(names(parsed_taxa)[[1]], "taxa")
expect_equal(parsed_taxa[[1]][[1]][["family"]], "Aceraceae")
expect_equal(parsed_taxa[[1]][[1]][["genus"]], "Acer")
expect_equal(parsed_taxa[[1]][[1]][["family"]], jsonlite::unbox("Aceraceae"))
expect_equal(parsed_taxa[[1]][[1]][["genus"]], jsonlite::unbox("Acer"))
expect_true(is.na(parsed_taxa[[1]][[1]][["species"]]))
})

Expand Down

0 comments on commit b52ad03

Please sign in to comment.