AWS iOT Integration - Parsing Embedded Data

We have an integration to AWS iOT Core. We are using he Cayenne LPP integration. I want to store the rssi and snr in the first gateways array element into AWS DymoDB. I am looking for anyone’s help with syntax. I know javascript would reference the data as meteadata.gateways[0].rssi and metadata.gateways[0].snr but using the square brackets in the AWS iOT rule is not allowed. Does anyone know if I can use metadata.gateways(0).snr and metedata.gatweays(0).rssi in the IOT rules?

Here is a working version of the rule that properly sends all of the data to DynamoDB

SELECT dev_id, metadata.time AS PACKET_TIMESTAMP, payload_fields.analog_in_1, payload_fields.analog_in_2, payload_fields.analog_in_3, 
payload_fields.analog_in_4, payload_fields.analog_in_5, payload_fields.digital_in_1, 
payload_fields.temperature_3, payload_fields.temperature_6 
FROM 'ssd_sod/devices/+/up'

Here is the JSON mqtt packet that is being sent:

{
  "app_id": "ssd_sod",
  "dev_id": "sensor2-water-level",
  "hardware_serial": "0059D801135A5F78",
  "port": 1,
  "counter": 48,
  "payload_raw": "A2cC5AEADwICAaM=",
  "payload_fields": {
    "analog_in_2": 4.19,
    "digital_in_1": 15,
    "temperature_3": 74
  },
  "metadata": {
    "time": "2019-12-12T19:35:12.819735858Z",
    "frequency": 903.9,
    "modulation": "LORA",
    "data_rate": "SF7BW125",
    "airtime": 61696000,
    "coding_rate": "4/5",
    "gateways": [
      {
        "gtw_id": "iotdev",
        "gtw_trusted": true,
        "timestamp": 2649059779,
        "time": "",
        "channel": 0,
        "rssi": -120,
        "snr": -2.5,
        "rf_chain": 0,
        "latitude": 26.300394,
        "longitude": -81.42677
      }
    ]
  }
}

Did you try? And did you try the get function? Like, maybe, get(metadata.gateways, 0).snr?

That worked. Thank you for your help

Nice. But beware: I doubt the list of arrays is explicitly sorted some specific way. So, you’re getting the SNR and RSSI of the first gateway in the list, which might not be the one with the best reception, I think. Maybe storing the full gateways value is easier/better?