| objectAsJSON {XR} | R Documentation |
Construct a String in JSON Notation to Represent an R Object
Description
The XR structure requires a server-language function objectFromJSON() which
parses an object description in JSON. Methods for generic function objectAsJSON()
should produce the appropriate string.
Usage
objectAsJSON(object, prototype = prototypeObject(), level = 1)
## S4 method for signature 'array'
objectAsJSON(object, prototype = prototypeObject(),
level = 1)
## S4 method for signature 'environment'
objectAsJSON(object, prototype = prototypeObject(),
level = 1)
## S4 method for signature 'list'
objectAsJSON(object, prototype = prototypeObject(),
level = 1)
## S4 method for signature 'envRefClass'
objectAsJSON(object, prototype = prototypeObject(),
level = 1)
## S4 method for signature 'Interface'
objectAsJSON(object, prototype = prototypeObject(),
level = 1)
## S4 method for signature 'AssignedProxy'
objectAsJSON(object, prototype = prototypeObject(),
level = 1)
## S4 method for signature 'ProxyClassObject'
objectAsJSON(object,
prototype = prototypeObject(), level = 1)
Arguments
object |
The object to be converted. |
prototype |
The prototype server class; see |
level |
Will be 1 for top-level call, incremented when recalled for an element. Used to make choices about scalars. |
Details
This function is typically called from a method for asServerObject.
Methods for objectAsJSON() in turn often call one or both of two helper functions:
asJSONS4(), which produces the full description of the R object; and
typeToJSON(), which produces the code for the basic R types, ignoring all
class or attribute information.
Value
A string that will be parsed according to JSON grammar.
Methods (by class)
-
array: treat matrix and array objects as legitimate S3 objects -
environment: An environment is encoded with its class, in contrast to a named list which may be a simple dictionary. -
list: A list will be encoded as a JSON list if it has no names, as a JSON dictionary if it has all distinct, non-empty names, or with an explicit representation in all other cases. -
envRefClass: An explicit representation that includes the fields. -
Interface: An interface object is transmitted via its character string Id, enough to identify the object; the rest is too R-dependent to be useful. -
AssignedProxy: Gets the object back from the server, then recalls the generic. It's usually not a good idea to get here, because bringing the proxy back and then converting it again is not foolproof; better to make direct use of the proxy. But if a proxy object is part of an ordinary list, environment or other R object, this method will be used. -
ProxyClassObject: Gets the object back from the server, then recalls the generic. See the comments under the"AssignedProxy"method.
References
Chambers, John M. (2016) Extending R, Chapman & Hall/CRC. ( Chapter 13, discussing this package, is included in the package: ../doc/Chapter_XR.pdf.)