Learn R Programming

jsontools (version 0.1.0)

json_merge: Merge two JSON objects

Description

By merging two objects you can add, modify, or remove elements of an object. Arrays cannot be modified but only replaced as a whole. It is mostly a small wrapper around the SQLite function json_patch().

Usage

json_merge(x, y)

Arguments

x

A JSON vector to update.

y

A JSON vector with updated values.

Value

A json2 vector.

Examples

Run this code
# NOT RUN {
# update element with key "a"
json_merge('{"a": 1, "c": 3}', '{"a": 11}')

# you can also add elements
json_merge('{"a": 1, "c": 3}', '{"b": 2}')

# remove elements with `null`
json_merge('{"a": 1, "c": 3}', '{"c": null}')
# }

Run the code above in your browser using DataLab