duncantl / RJSONIO

Serialize to and from R and JSON, JavaScript Object Notation
http://www.omegahat.org/RJSONIO
Other
25 stars 68 forks source link

AsIs object for [] #11

Open jeroen opened 10 years ago

jeroen commented 10 years ago

In RJSONIO a [] json string gets converted to an AsIs object, see here. What is the reasoning behind this?

> library(RJSONIO)
> fromJSON("[]")
list()
> is(fromJSON("[]"))
[1] "AsIs"     "oldClass"
> is(fromJSON("[]"), "list")
[1] FALSE
duncantl commented 10 years ago

Hi Jeroen AFAIR, this was to ensure round-tripping worked in cases where there was some ambiguity. I can't recall if this is still necessary. But basically it is where an object degenerates to a scalar, for example, and it needs to be mapped back to a vector. But this is not the case here, but it is in that spirit.