R: Create handler for processing JSON elements from a parser
basicJSONHandler
R Documentation
Create handler for processing JSON elements from a parser
Description
This function creates a handler object that is used to
consume tokens/elements from a JSON parser and combine
them into R objects.
This is slow relative to using C code because this is done
in R and also we don't know the length of each object until
we have consumed all its elements.
the best guess as to the sizes of the different elements. This is used
for preallocating space for elements
simplify
a logical value indicating whether to simplify arrays
from lists to vectors if the elements are of compatible types.
Value
update
a function called with a JSON element and used to process that element and add it to the relevant R object
value
a function to retrieve the result after processing the JSON
Author(s)
Duncan Temple Lang
See Also
fromJSON and the handler argument.
Examples
h = basicJSONHandler()
x = fromJSON("[1, 2, 3]", h)
x
h$value()
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(RJSONIO)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RJSONIO/basicJSONHandler.Rd_%03d_medium.png", width=480, height=480)
> ### Name: basicJSONHandler
> ### Title: Create handler for processing JSON elements from a parser
> ### Aliases: basicJSONHandler
> ### Keywords: IO programming
>
> ### ** Examples
>
> h = basicJSONHandler()
> x = fromJSON("[1, 2, 3]", h)
> x
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 3
> h$value()
[[1]]
[1] 1
[[2]]
[1] 2
[[3]]
[1] 3
>
>
>
>
>
> dev.off()
null device
1
>