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
asked a month ago90 views
1 Answer
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
answered 25 days ago
profile picture
EXPERT
reviewed 24 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions