blockr_ser | R Documentation |
Object serialization is available via to_json()
, while de-serialization
is available as from_json()
. Blocks are serialized by writing out
information on the constructor used to create the object, combining this
with block state information, which constitutes values such that when passed
to the constructor the original object can be re-created.
blockr_ser(x, ...)
## S3 method for class 'block'
blockr_ser(x, state = NULL, ...)
## S3 method for class 'blocks'
blockr_ser(x, blocks = NULL, ...)
## S3 method for class 'board_options'
blockr_ser(x, options = NULL, ...)
## S3 method for class 'board'
blockr_ser(x, blocks = NULL, options = NULL, ...)
## S3 method for class 'link'
blockr_ser(x, ...)
## S3 method for class 'links'
blockr_ser(x, ...)
## S3 method for class 'stack'
blockr_ser(x, ...)
## S3 method for class 'stacks'
blockr_ser(x, ...)
blockr_deser(x, ...)
## S3 method for class 'list'
blockr_deser(x, ...)
## S3 method for class 'block'
blockr_deser(x, data, ...)
## S3 method for class 'blocks'
blockr_deser(x, data, ...)
## S3 method for class 'board'
blockr_deser(x, data, ...)
## S3 method for class 'link'
blockr_deser(x, data, ...)
## S3 method for class 'links'
blockr_deser(x, data, ...)
## S3 method for class 'stack'
blockr_deser(x, data, ...)
## S3 method for class 'stacks'
blockr_deser(x, data, ...)
## S3 method for class 'board_options'
blockr_deser(x, data, ...)
to_json(x, ...)
from_json(x)
x |
Object to (de)serialize |
... |
Generic consistency |
state |
Object state (as returned from an |
blocks |
Block states ( |
options |
Board option values ( |
data |
List valued data (converted from JSON) |
Helper functions blockr_ser()
and blockr_deser()
are implemented as
generics and perform most of the heavy lifting for (de-)serialization:
representing objects as easy-to-serialize (nested) lists containing mostly
strings and no objects which are hard/impossible to truthfully re-create in
new sessions (such as environments).
Serialization helper function blockr_ser()
returns lists, which
for most objects contain slots object
and payload
, where object
contains a class vector which is used by blockr_deser()
to instantiate an
empty object of that class and use S3 dispatch to identify the correct method
that, given the content in payload
, can re-create the original object.
These are wrapped by to_json()
, which returns JSON and from_json()
which
can consume JSON and returns the original object.
blk <- new_dataset_block("iris")
blockr_ser(blk)
to_json(blk)
all.equal(blk, blockr_deser(blockr_ser(blk)), check.environment = FALSE)
all.equal(blk, from_json(to_json(blk)), check.environment = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.