try 创建一个哨兵查询(Kql),该查询使用外部数据()操作符从JSON文件‘https://www.gov.uk/bank-holidays.json’.‘获取信息我发现的问题是由于这个包含列/字段‘date’的json文件不允许将其作为变量.有没有人能够从外部文件中获得多层json字段?

externaldata (title:string, date:string, notes:string, bunting:bool)[
    @"https://www.gov.uk/bank-holidays.json"
    ]
    with(format="multijson")

推荐答案

  1. The externaldata operator was created to enable users of Azure Data Explorer (AKA Kusto) based SaaS systems, such as Log Analytics and Application Insights, to work with external data located in Azure storage.
    Retrieving data from web sites in an unsupported scenario.
    Sometimes it works, and sometimes not (depends on what lies on the other side).
    For your specific URL, it does not work.
  2. KQL中的特殊名称可以用方括号和单/双限定词来表示,例如['date']["date"]
  3. 整个文档被写在一行中.json个就够了.不需要multijson.
  4. The assumed schema is wrong (title:string, date:string, notes:string, bunting:bool).
    The JSON has 3 keys in the 1st layer, one for each kingdom: "england-and-wales", "scotland" & "northern-ireland".
  5. 虽然我们可以使用上面的键来读取JSON,但我更喜欢将其读取为txtraw,将其解析为JSON,然后分解它,如下面的查询所示.
externaldata(doc:string)
[h'https://<storage-account-name>.blob.core.windows.net/mycontainer/bank-holidays.json;<secret>']
with(format='txt')
| project parse_json(doc)
| mv-expand kind=array doc
| project   kingdom  = tostring(doc[0])
           ,division = doc[1].division
           ,events   = doc[1].events
| mv-expand events
| evaluate bag_unpack(events) 
//| sample 10
kingfom division bunting date notes title
northern-ireland northern-ireland false 2017-04-14T00:00:00Z Good Friday
england-and-wales england-and-wales true 2017-05-29T00:00:00Z Spring bank holiday
scotland scotland false 2018-03-30T00:00:00Z Good Friday
england-and-wales england-and-wales true 2018-12-25T00:00:00Z Christmas Day
northern-ireland northern-ireland false 2019-04-19T00:00:00Z Good Friday
england-and-wales england-and-wales true 2019-12-25T00:00:00Z Christmas Day
northern-ireland northern-ireland true 2020-01-01T00:00:00Z New Year’s Day
scotland scotland true 2022-01-04T00:00:00Z Substitute day 2nd January
scotland scotland false 2022-09-19T00:00:00Z Bank Holiday for the State Funeral of Queen Elizabeth II
scotland scotland true 2023-01-02T00:00:00Z Substitute day New Year’s Day

Json相关问答推荐

使用SQL查询从SON中查找第n个密钥对值

JOLT将对象名作为新属性添加到主体中

如何使用PowerShell从ExchangeOnline命令执行中获得JSON输出

使用JQ将JSON输出转换为CSV复杂 struct

错误解析错误:意外令牌:在我的 .eslintrc.json 文件中.为什么?

将 JSON 解组为具有唯一元素的 map 切片

如何在linux中用jq过滤json数组?

将哈希表转换为 json 后,Powershell 缺少数组

自定义将 struct 解组为切片映射

如何在 onClick 事件处理程序中识别在同一 map 上绘制的多个多边形中的哪个(使用 react-leaflet)被单击?

hook到 Decodable.init() 以获得未指定的键?

如何在 jQuery 中循环遍历 JSON 数组?

如何使用 gson 调用默认反序列化

苗条的 JSON 输出

Android JSON 库的性能和可用性比较

jquery用json数据填充下拉列表

如何在 json 编码字符串内的子数组数据周围添加方括号?

如何从 JSON 响应中提取单个值?

如何从 github API 解析链接头

用 JSON 编写 HTML 字符串