如何在 Azure 数据资源管理器中对 JSON 对象进行动态联接

How to do a dynamic join in a JSON object in Azure Data Explorer

我有一个嵌套的 json 字符串,我正在使用 parse_json() 函数对其进行解析。样本数据看起来像

{ "one":"OneValue", "four""FourValue", {"1":"stringA", "24":"stringBlah"..}}

嵌套 json 字符串中的值“1”和“24”是映射 table.

的键

示例映射 table 数据 “1”:"One" “24”:"TwentyFour"

我想将嵌套 json 中的键与映射 table 连接起来,并有一个输出值而不是键的查询。关于如何在键上进行动态连接有什么建议吗?

我不完全确定我是否正确理解了您的意图,但以下内容可能会为您指明方向:

let T1 = datatable(d:dynamic)
[
    dynamic({ "one":"OneValue", "four": "FourValue", "prop":{"1":"stringA", "24":"stringBlah"}}),
    dynamic({ "one":"OneValue", "four": "FourValue", "prop":{"3":"stringB", "24":"stringBlahBlah"}})
]
;
let T2 = datatable(i:int, s:string)
[
    1,  "One",
    24, "TwentyFour",
    3,  "Three"
]
;
let map = toscalar(
    T2
    | summarize make_bag(pack(tostring(i), s))
)
;
T1
| project prop = d.prop
| mv-apply prop on 
(
    extend key = tostring(bag_keys(prop)[0])
    | project p = pack(tostring(map[key]), prop[tostring(key)])
    | summarize result = make_bag(p)
)

这个returns:

|result                                              |
|----------------------------------------------------|
|{"One":   "stringA", "TwentyFour": "stringBlah"}    |
|{"Three": "stringB", "TwentyFour": "stringBlahBlah"}|