When converting from JSON to R it seems logical that a JSON array would
correspond to an "unnamed" R list, while a JSON object would correspond to a
"named" R list.  E.g.
JSON: [1, 3.1415927, "foo", false, null]   => R: list(1, 3.1415927, "foo",
FALSE, NA);

and

JSON { "int": 1, "float": 3.1415927, "string": "foo", "logical": false,
"null": null }  => R: list(int=1, float=3.1415927, string="foo",
logical=FALSE, null=NA)

But I see at least a couple of problems with this scheme.  First, how would
one distinguish between the R versions of an empty JSON array (i.e. [ ]),
and an empty JSON object (i.e. { })?

Second, JSON allows the empty key in an object (e.g., this is a valid JSON
object: { "": 123 }), but as far as I can tell, R does not allow the empty
string as a name in a named list:

> list(""=123)
Error: attempt to use zero-length variable name



Any suggestions for dealing with these edge cases would be much appreciated!

TIA!

kynn

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to