Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

basicJSONHandler

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.

Usage

basicJSONHandler(default.size = 100, simplify = FALSE)

Arguments

default.size

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()

RJSONIO

Serialize R Objects to JSON, JavaScript Object Notation

v1.3-1.4
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2014), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>), Jonathan Wallace [aut] (aka ninja9578, author of included libjson sources)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.