json_merge: Merge two JSON objects

View source: R/modify.R

json_mergeR Documentation

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

# 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}')

mgirlich/jsontools documentation built on March 21, 2023, 9:10 a.m.