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

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ