Azure流分析查询JSON

问题描述 投票:0回答:1

我在编写查询以从json文件中提取数组中的表时遇到问题:问题是如何获取数组“clientPerformance”的信息,然后将它们全部放在普通的sql表中。

该文件如下所示:

"clientPerformance":[  
        {  
         "name":"opportunity",
         "clientProcess":{  
            "value":3620000.0,
            "count":1.0,
            "min":3620000.0,
            "max":3620000.0,
            "stdDev":0.0,
            "sampledValue":3620000.0
         },
         "networkConnection":{  
            "value":10000.0,
            "count":1.0,
            "min":10000.0,
            "max":10000.0,
            "stdDev":0.0,
            "sampledValue":10000.0
         },
         "receiveRequest":{  
            "value":9470000.0,
            "count":1.0,
            "min":9470000.0,
            "max":9470000.0,
            "stdDev":0.0,
            "sampledValue":9470000.0
         },
         "sendRequest":{  
            "value":1400000.0,
            "count":1.0,
            "min":1400000.0,
            "max":1400000.0,
            "stdDev":0.0,
            "sampledValue":1400000.0
         },
         "total":{  
            "value":14500000.0,
            "count":1.0,
            "min":14500000.0,
            "max":14500000.0,
            "stdDev":0.0,
            "sampledValue":14500000.0
         },
         "url":"https://xxxx",
         "urlData":{  
            "base":"/main.aspx",
            "host":"xxxx",
            "hashTag":"",
            "protocol":"https"
         }
      }
   ]

我试图使用Get数组元素方法和其他方法,但我永远无法访问clientProcess,networkConnection ..元素

我试图用这个例子:

Select 
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'name') AS Name,
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 1), 'clientProcess.count') AS clientProcessCount,
FROM [app-insights-blob-dev] Input 

我将不胜感激任何帮助 :)

json azure azure-stream-analytics
1个回答
1
投票

我稍微编辑了您的查询以返回clientProcessCount。 (我将数组索引从1更改为0)。还要确保您的JSON对象以{开头}结束。

Select
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'name') AS Name,
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'clientProcess.count') AS clientProcessCount
FROM [app-insights-blob-dev] Input

对于使用ASA查询复杂对象的其他示例,请不要犹豫,看看这个blog post

© www.soinside.com 2019 - 2024. All rights reserved.