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
gefragt vor 2 Monaten100 Aufrufe
1 Antwort
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
SUPPORT-TECHNIKER
Bony_T
beantwortet vor einem Monat
profile picture
EXPERTE
überprüft vor einem Monat

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen