JSON (JavaScript Object Notation) allows to specify fairly complex
objects that can be rather easily exchanged between languages. The notation
is also human-readable and not too difficult to edit manually (although not
advised, of course). However, JSON has too many limitations to represent R
objects (no NA
versus NaN
, no infinite numbers, no distinction between
lists and objects with attributes, or S4 objects, etc.). Moreover, JSON is
not very easy to interpret in R and the existing implementations can convert
only specified objects (simple objects, lists, data frames, ...).
RJSON slighly modifies and enhances JSON to make it: (1) more complete to
represent almost any R object (except objects with pointers, environments,
..., of course), and (2) to make it very easy to parse and evaluate in both
R and JavaScript (and probably many other) languages.
With attributes = FALSE
, factors and Dates are converted to their usual
character representation before encoding the RJSON object. If
attributes = TRUE
, they are left as numbers and their attributes (class,
-and levels for factor-) completely characterize them (i.e., using
eval_rjson()
and such objects recreate factors or Dates, respectively).
However, they are probably less easy to handle in JavaScript of other
language where you import the RJSON representation.
Note also that a series of objects are not yet handled correctly. These
include: complex numbers, the different date flavors other that Date,
functions, expressions, environments, pointers. Do not use such items in
objects that you want to convert to RJSON notation.
A last restriction: you cannot have any special characters like linefeed,
tabulation, etc. in names. If you want to make your names most compatible
with JavaScript, note that the dot is not allowed in syntactically valid
names, but the dollar sign is allowed.