Learn R Programming

jsonlite (version 1.8.4)

gzjson: Gzipped JSON

Description

Wrapper to generate and parse gzipped JSON, in order to save some disk or network space. This is mainly effective for larger json objects with many repeated keys, as is common in serialized data frames.

Usage

as_gzjson_raw(x, ...)

as_gzjson_b64(x, ...)

parse_gzjson_raw(buf, ...)

parse_gzjson_b64(b64, ...)

Arguments

x

R data object to be converted to JSON

...

passed down to toJSON or fromJSON

buf

raw vector with gzip compressed data

b64

base64 encoded string containing gzipped json data

Details

The as_gzjson_raw and parse_gzjson_raw functions work with raw (binary) vectors of compressed data. To use this in a place where only text is allowed you can wrap the output again in base64 as done by as_gzjson_b64 and parse_gzjson_b64. This increases the size again with about 33%.

Examples

Run this code
str <- as_gzjson_b64(iris[1:5,])
cat(str)
parse_gzjson_b64(str)

Run the code above in your browser using DataLab