Description Usage Arguments Details Value Examples
A wrapper around the great jsonlite::parse_json. The differences are:
expose argument bigint_as_char with default TRUE.
control how to handle NA and NULL.
simplifyDataFrame, simplifyMatrix, and flatten default to FALSE as
they are not very stable in many real world APIs. Use the
tibblify package
for a more robust conversion to a dataframe.
don't collapse strings but error instead if they have more than one element.
1 2 3 4 5 6 7 8 9 10 11 | parse_json(
x,
.na = json_na_error(),
.null = NULL,
simplifyVector = TRUE,
simplifyDataFrame = FALSE,
simplifyMatrix = FALSE,
flatten = FALSE,
bigint_as_char = bigint_default(),
...
)
|
x |
a scalar JSON character |
.na |
Value to return if |
.null |
Return the prototype of |
simplifyVector, simplifyDataFrame, simplifyMatrix, flatten, ... |
passed on
to |
bigint_as_char |
Parse big integers as character? The option
|
To parse a vector of JSON use parse_json_vector.
A R object. The type depends on the input but is usually a list or a data frame.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Parse escaped unicode
parse_json('{"city" : "Z\\u00FCrich"}')
# big integers
big_num <- "9007199254740993"
as.character(parse_json(big_num, bigint_as_char = FALSE))
as.character(parse_json(big_num, bigint_as_char = TRUE))
# NA error by default
try(parse_json(NA))
# ... but one can specify a default value
parse_json(NA, .na = data.frame(a = 1, b = 2))
# input of size 0
parse_json(NULL)
parse_json(character(), .null = data.frame(a = 1, b = 2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.