RJSONIO
RJSONIO copied to clipboard
fromJSON with simplify=T and nulls
I think I found an inconsistency in the way fromJSON handles null in strings when simplify=T. See those two examples here:
> fromJSON("[ 1, 2, 3, null, 4 ]", asText=T, simplify=T)
[1] 1 2 3 NA 4
> fromJSON("[ \"a\", \"b\", \"c\", null, \"d\" ]", asText=T, simplify=T)
[1] "a" "b" "c" "" "d"
I would have expected the null to be converted to NA_character_, not an empty string.
Notice how those two very different JSON entries become the same (and IMHO that is undesirable):
> fromJSON("[ \"a\", \"b\", \"c\", null, \"d\" ]", asText=T, simplify=T)
[1] "a" "b" "c" "" "d"
> fromJSON("[ \"a\", \"b\", \"c\", \"\", \"d\" ]", asText=T, simplify=T)
[1] "a" "b" "c" "" "d"
Thanks. I committed a minor change which seems to resolve the issue and leave other things working the way the previously did. Thanks.
Thank you for fixing this so quickly, and for providing this very useful package in the first place. :)