我想知道是否可以有一个用户定义的 .js,从我的流分析中的 Json 字符串解码 Base64。我有多少自由可以使用任何 js 函数,或者是否有预设数量的函数可以使用。我尝试使用 atob(),但 SAnalytic 告诉我:
函数 'base64decod' 导致错误:'ReferenceError: 'atob' is not defined' Stack: ReferenceError: 'atob' is not defined at main (Unknown script code:3:4)
UDF:
function main(arg1) {
var decodData = atob(arg1);
return decodData;
}
询问:
SELECT
[SystemProperties].[connectionDeviceId], temp, hum, rssi, snr,
EventProcessedUtcTime, UDF.base64decod(Body)
INTO
[intoData]
FROM
[fromBlob]
JSON 片段:
{
"EnqueuedTimeUtc": "2019-12-09T12:39:08.3320000Z",
"Properties": {},
"SystemProperties": {
"to": "/devices/device-03/messages/events",
"connectionDeviceId": "device-03",
"connectionAuthMethod": "{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}",
"connectionDeviceGenerationId": "xxxxxxxxx025137526",
"contentEncoding": "",
"enqueuedTime": "2019-12-09T12:39:08.3320000Z"
},
"Body": "eyJ0ZW1wIjoxLjc1LCJodW0iOjYxLjYzLCJyc3NpIjotMTAzLCJzbnIiOjguMn0=",
"EventProcessedUtcTime": "2019-12-09T12:42:07.9089000Z",
"PartitionId": 0,
"BlobName": "measurements/iotc-xxxxxxxxxxxxxxxx/2019/12/09/12/40/01.json",
"BlobLastModifiedUtcTime": "2019-12-09T12:41:06.0000000Z"
},
非常感谢您的帮助!