Learn R Programming

jsontools (version 0.1.0)

json_mutate: Update values

Description

Update values

Usage

json_mutate(x, ...)

Arguments

x

A JSON vector.

...

Name-value pairs. The name is the JSON path (without leading "$").

Value

A json2 vector similar to x with the components modified as specified in ....

Examples

Run this code
# NOT RUN {
x_na <- c('{"a": 11, "b": {"x": 12}}', NA, '{"a": 21, "b": {"x": 22}}')
# update with different values
json_mutate(x_na, .a = 1:3)

# NA is translated to null
json_mutate(x_na, .a = 1:3, .b.x = NA)

# create new keys
json_mutate(x_na, .c = 0, .d.x = c("a", "b", "c"))
# }

Run the code above in your browser using DataLab