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

list. The new JSON list.

json_old

list. The old JSON list.

sep

character. A character/string passed to flattenj. Defaults to @ to avoid the occasional overriding. Not recommended to use some risky characters like . and \.

primary

character. The primary path(keys) for identifying a unique JSON object. The value provided should contain the sep value to specify the nesting information unless it is an outermost key.

Details

The function borrows the idea from the data set operation, and the result contains:

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

[Package mojson version 0.1 Index]