Dot "." operator in JSON field name IoT core

0

Hello I receive JSON like: { "peer": "37.47.128.172:21477", "position.latitude": 49.692065, "position.longitude": 20.497348 } And i try create rule in IoT core for message routing :

SELECT position.latitude, position.longitude FROM 'myTopic'.

It doesn't work bcs "." Operator this operator accesses members in embedded JSON objects. How can I fix my SQL script?

  • Solution: SELECT position_latitude, position_longitude FROM 'myTopic'.

    change . to _

Kamil
已提问 2 个月前100 查看次数
1 回答
0

You can use

SELECT get(*,"position.latitude") as latitude ,get(*,"position.longitude") as longitude FROM 'testTopic' 

to extract the data. The output will be like

{
  "latitude": 49.692065,
  "longitude": 20.497348
}

ref: https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-json.html

profile pictureAWS
支持工程师
Bony_T
已回答 1 个月前
profile picture
专家
已审核 1 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则