-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
By default, the insertion order is not preserved; but usually in R related tasks preserving the order of the object elements is important, i.e., reconstruct data-frames from jsons.
l <- list(Jan = 1L, Feb = 2L, Mar = 3L)
j1 <- yyjsonr::write_json_str(l, auto_unbox = TRUE)
j1
# {"Jan":1,"Feb":2,"Mar":3}
# Default behaviour: object keys are sorted alphabetically
jstring <- jsonString$new(j1)
jstring
# {
# "Feb": 2,
# "Jan": 1,
# "Mar": 3
# }
all.equal(jstring$asString(), j1)
# "1 string mismatch"
# Or reconstruct to list
l2 <- yyjsonr::read_json_str(jstring$asString())
all.equal(l, l2)
# [1] "Names: 2 string mismatches"
# [2] "Component 1: Mean relative difference: 1"
# [3] "Component 2: Mean relative difference: 0.5"
Metadata
Metadata
Assignees
Labels
No labels