colearendt / tidyjson

Tidy your JSON data in R with tidyjson
Other
182 stars 14 forks source link

Additional Options for as.character() #102

Open colearendt opened 7 years ago

colearendt commented 7 years ago

as.character.tbl_json uses jsonlite::toJSON behind the scenes. However, jsonlite::toJSON has multiple parameters that ought to either be selected wisely or passed along to the user (with ..., perhaps).

In particular:

library(jsonlite)

jsonlite::toJSON(0.123456789,auto_unbox=TRUE)
# 0.1234

jsonlite::toJSON(0.123456789,auto_unbox=TRUE,digits=10)
# 0.123456789

For the digits parameter, at least, setting digits=NA will preserve decimal integrity and is probably a better option in as.character than the default of 4.