Learn R Programming

jsonNormalize (version 1.0.0)

jsonNormalize: Normalize a JSON string

Description

Attempts to normalize or fix a JSON string. Trailing commas are removed, and all keys of the normalized JSON string are double-quoted.

Usage

jsonNormalize(jstring, prettify = FALSE, to = NULL)

Value

The normalized JSON string.

Arguments

jstring

a character string, the JSON string to be normalized, or the path to a JSON file

prettify

Boolean, whether to prettify the normalized JSON string

to

NULL to return the normalized JSON string, otherwise the path to a JSON file to which the normalized JSON string will be written

Examples

Run this code
library(jsonNormalize)
# the keys of the following JSON string are not quoted
jstring <- "[{area:30,ind:[5,3.7], cluster:true,},{ind:[],cluster:false},]"
cat(jsonNormalize(jstring, prettify = TRUE))

Run the code above in your browser using DataLab