JSON 从 Particle Photon Webhook 格式化到 Azure
JSON Formatting from Particle Photon Webhook to Azure
我连接了我的 Particle Photon 来记录我的温度,然后将事件发布到 Microsoft Azure 的 eventhub。然后我使用 Stream Analytics 将 JSON 文件输出到 Azure 存储中(好主意?还是不好?)。
当我尝试通过 HTML 使用 <script src="URL"></script>
打开它时,我在浏览器控制台中得到 " 未捕获的语法错误:意外标记:" window。
我还尝试使用 JSON 格式化程序验证我的 JSON 文件,但出现了很多错误。
这是 JSON 文件:https://pptlbhstorage.blob.core.windows.net/temperature/0_d1e8a2b709b14461b5ac12265f33020b_1.json
根据流分析,我使用此查询创建了一个作业:
CREATE TABLE pptlbhhub (
coreid nvarchar(max),
data nvarchar(max),
event nvarchar(max),
EventEnqueuedUtcTime datetime,
EventProcessedUtcTime datetime,
measurename nvarchar(max),
PartitionId bigint,
published_at datetime,
subject nvarchar(max),
timecreated datetime,
unitofmeasure nvarchar(max),
value float
);
SELECT
coreid
,event
,EventEnqueuedUtcTime
,EventProcessedUtcTime
,measurename
,PartitionId
,published_at
,subject
,timecreated
,unitofmeasure
,value
INTO
pptlbhstorage
FROM
pptlbhhub;
如果您将事件输出为数组,您的 JSON 文件就可以了:
[{}, {}, ...]
代替
{} {} {} ...
我的意思是您的文件应该看起来像这样 JSON 有效(就像一个数组)。
[{"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56:20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location": "Oslo","measurename":"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08 :56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F", "value":21.0},
{"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56: 20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location":"Oslo","measurename" :"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08:56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F","value":21.0}, ...]
不喜欢
{"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56: 20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location":"Oslo","measurename" :"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08:56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F","value":21.0}
{"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56: 20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location":"Oslo","measurename" :"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08:56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F","value":21.0}...
区别在于流首&末尾的“[]”和每个元素之间的“,”
您可能会对 Particle 与 Azure IoT 中心的第一次 class 集成感兴趣,以帮助您将 Particle 设备数据导入 Microsoft Azure。有关如何设置此设置的更多信息,请查看:
https://docs.particle.io/tutorials/integrations/azure-iot-hub/
我连接了我的 Particle Photon 来记录我的温度,然后将事件发布到 Microsoft Azure 的 eventhub。然后我使用 Stream Analytics 将 JSON 文件输出到 Azure 存储中(好主意?还是不好?)。
当我尝试通过 HTML 使用 <script src="URL"></script>
打开它时,我在浏览器控制台中得到 " 未捕获的语法错误:意外标记:" window。
我还尝试使用 JSON 格式化程序验证我的 JSON 文件,但出现了很多错误。
这是 JSON 文件:https://pptlbhstorage.blob.core.windows.net/temperature/0_d1e8a2b709b14461b5ac12265f33020b_1.json
根据流分析,我使用此查询创建了一个作业:
CREATE TABLE pptlbhhub (
coreid nvarchar(max),
data nvarchar(max),
event nvarchar(max),
EventEnqueuedUtcTime datetime,
EventProcessedUtcTime datetime,
measurename nvarchar(max),
PartitionId bigint,
published_at datetime,
subject nvarchar(max),
timecreated datetime,
unitofmeasure nvarchar(max),
value float
);
SELECT
coreid
,event
,EventEnqueuedUtcTime
,EventProcessedUtcTime
,measurename
,PartitionId
,published_at
,subject
,timecreated
,unitofmeasure
,value
INTO
pptlbhstorage
FROM
pptlbhhub;
如果您将事件输出为数组,您的 JSON 文件就可以了: [{}, {}, ...] 代替 {} {} {} ...
我的意思是您的文件应该看起来像这样 JSON 有效(就像一个数组)。 [{"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56:20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location": "Oslo","measurename":"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08 :56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F", "value":21.0}, {"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56: 20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location":"Oslo","measurename" :"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08:56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F","value":21.0}, ...]
不喜欢 {"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56: 20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location":"Oslo","measurename" :"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08:56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F","value":21.0} {"coreid":"1e0041000c47343432313031","displayname":"IoT Assignment 3","event":"PublishToEventHub","eventenqueuedutctime":"2016-05-12T08:56: 20.5300000Z","eventprocessedutctime":"2016-05-12T08:56:21.3068971Z","guid":"1e0041000c47343432313031","location":"Oslo","measurename" :"Temperature","organization":"Westerdals ACT","partitionid":0,"published_at":"2016-05-12T08:56:21.0850000Z","subject":"Weather","timecreated":"2016-05-12T08:56:21.0850000Z","unitofmeasure":"F","value":21.0}...
区别在于流首&末尾的“[]”和每个元素之间的“,”
您可能会对 Particle 与 Azure IoT 中心的第一次 class 集成感兴趣,以帮助您将 Particle 设备数据导入 Microsoft Azure。有关如何设置此设置的更多信息,请查看:
https://docs.particle.io/tutorials/integrations/azure-iot-hub/