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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南