jsonlite icon indicating copy to clipboard operation
jsonlite copied to clipboard

Feature request: specify `na` strings in `fromJSON`

Open gregorp opened this issue 10 years ago • 1 comments

Most R import/export data tools have the ability to customize the NA strings. It would be neat if jsonlite did this too.

I'd imagine something like

fromJSON('["a", "b", "."]', na = ".")
#  "a" "b" NA

For consistency, the way the na argument in toJSON would also need to be modified to allow

toJSON(c("a", "b", NA), na = ".")
# ["a","b","."] 

I got the idea from some guy's SO post.

I could probably fork, modify, and submit a pull request in the next week or two if you're interested.

gregorp avatar Apr 29 '15 20:04 gregorp

I am having a related problem.

I'm reading a JSON string that contains the strings "NA" - and I need them to remain as character class, not R's reserved NA value.

If the above is implemented, and I could specify na=NULL to have no JSON string values convert to NAs, that would be useful.

rcalme avatar Aug 31 '16 15:08 rcalme