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

tojson-crunch

toJSON methods for Crunch objects


Description

crunch uses the jsonlite package for JSON serialization and deserialization. Unfortunately, jsonlite::toJSON() does not allow for defining S4 methods for other object types. So, crunch::toJSON wraps jsonprep, which exists to translate objects to base R objects, which jsonlite::toJSON can handle. jsonprep is defined as an S4 generic, and it is exported, so you can define methods for it if you have other objects that you want to successfully serialize to JSON.

Usage

jsonprep(x, ...)

## S4 method for signature 'AbstractCategories'
jsonprep(x, ...)

## S4 method for signature 'ANY'
jsonprep(x, ...)

## S4 method for signature 'ShojiOrder'
jsonprep(x, ...)

## S4 method for signature 'OrderGroup'
jsonprep(x, ...)

toJSON(x, ..., for_query_string = FALSE)

Arguments

x

the object

...

additional arguments

for_query_string

If TRUE, and crunch.stabilize.query option is also set to TRUE, then dictionary items in the JSON are sorted alphabetically, which can be useful when capturing mocks using "httptest".

Value

jsonprep returns a base R object that jsonlite::toJSON can handle. toJSON returns the JSON-serialized character object.

See Also


crunch

Crunch.io Data Tools

v1.28.0
LGPL (>= 3)
Authors
Greg Freedman Ellis [aut, cre], Jonathan Keane [aut], Mike Malecki [aut], Neal Richardson [aut], Gordon Shotwell [aut]
Initial release

We don't support your browser anymore

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