Azure 流分析——查询 JSON 数组的数组

Azure Stream Analytics–Querying JSON Arrays of arrays

我在编写查询以从 json 文件的数组中提取 table 时遇到问题: 问题是如何获取数组“数据包”的信息及其数组的内容,然后让它们都正常sql table.

一个难题是 "CrashNotification" 和 "CrashMaxModuleAccelerations",我不知道如何定义和使用它们。

文件如下所示:


    { "imei": { "imei": "351631044527130F", "imeiNotEncoded":                         
"351631044527130" 
}, 
"dataPackets": [ [ "CrashNotification", { "version": 1, "id": 28 } ], [ 
"CrashMaxModuleAccelerations", { "version": 1, "module": [ -1243, -626, 
14048 ] } ] ]}

我尝试使用获取数组元素方法和其他方法,但我永远无法访问二级数组,例如 "dataPackets" 的 "CrashNotification" 的元素或 "module" 的元素"dataPackets".

的数组 "CrashMaxModuleAccelerations"

我也看过这里 (),但没有用。 如果有任何帮助,我将不胜感激:)

根据您的架构,下面是一个查询示例,它将提取具有以下列的 table:emei、crashNotification_version、crashNotification_id

WITH Datapackets AS
(
SELECT imei.imei as imei,
        GetArrayElement(Datapackets, 0) as CrashNotification
FROM input
)
SELECT  
    imei,
    GetRecordPropertyValue (GetArrayElement(CrashNotification, 1), 'version') as crashNotification_version,
    GetRecordPropertyValue (GetArrayElement(CrashNotification, 1), 'id') as crashNotification_id
FROM Datapackets

如果您有任何问题,请告诉我。

谢谢,

JS(Azure 流分析)

我们构建了一个名为 Stride 的 HTTP API,仅使用 SQL.

将流式 JSON 数据转换为实时、增量更新的表

您需要做的就是将原始 JSON 数据写入 Stride API 的 /collect endpoint, define continuous SQL queries via the /process endpoint, and then push or pull data via the /analyze 端点。

这种方法消除了处理任何底层数据基础设施的需要,并为您提供了一种基于 SQL 的方法来解决此类流分析问题。