json_merge: Merge two JSON objects

Description Usage Arguments Value Examples

View source: R/modify.R

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

1
json_merge(x, y)

Arguments

x

A JSON vector to update.

y

A JSON vector with updated values.

Value

A json2 vector.

Examples

1
2
3
4
5
6
7
8
# 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}')

jsontools documentation built on March 22, 2021, 5:06 p.m.