alignj {mojson} | R Documentation |
JSON Lists Alignment
Description
Align the two JSON lists by specifying the primary path(keys), to support the left/inner/right-join style comparison.
Usage
alignj(json_new, json_old, sep = "@", primary)
Arguments
json_new |
|
json_old |
|
sep |
|
primary |
|
Details
The function borrows the idea from the data set operation, and the result contains:
new
, contains the flattening result ofjson_new
.old
, contains the flattening result ofjson_old
.common_primary
, contains the primary paths both injson_new
andjson_old
.new_primary
, contains the primary paths only injson_new
.old_primary
, contains the primary paths only injson_old
.
Value
list
. The result list contains the alignment information of three types: the primary paths only in the new JSON,
only in the old JSON, and in both.
Examples
library(mojson)
j1 <- list(list(id = list(x = 1 ,y = 2), gender = 'M'),
list(id = list(x = 2 ,y = 2), gender = 'M'))
j2 <- list(list(id = list(x = 2 ,y = 2), gender = 'F'),
list(id = list(x = 3 ,y = 2), gender = 'F'))
alignj(j1, j2, primary = 'id@x')