Thursday, February 15, 2018

JSONata - Application Notes - Part 2


Original JSON:

{
"applicationID": "1",
"applicationName": "test_ds18b20",
"deviceName": "arduino_uno",
"devEUI": "1234567890123456",
"rxInfo": [{
"mac": "aa755a0048050130",
"rssi": -57,
"loRaSNR": 10,
"name": "raspberry_pi",
"latitude": 48.466860686785175,
"longitude": 35.019478797912605,
"altitude": 0
}],
"txInfo": {
"frequency": 868100000,
"dataRate": {
"modulation": "LORA",
"bandwidth": 125,
"spreadFactor": 7
},
"adr": true,
"codeRate": "4/5"
},
"fCnt": 9,
"fPort": 1,
"data": "Z29vZGJ5ZQ==",
"object": {}
}




Expression:  $keys()

Result:

[
  "applicationID",
  "applicationName",
  "deviceName",
  "devEUI",
  "rxInfo",
  "txInfo",
  "fCnt",
  "fPort",
  "data",
  "object"
]



Expression:  **.$keys()

Result:

[
  "applicationID",
  "applicationName",
  "deviceName",
  "devEUI",
  "rxInfo",
  "txInfo",
  "fCnt",
  "fPort",
  "data",
  "object",
  "mac",
  "rssi",
  "loRaSNR",
  "name",
  "latitude",
  "longitude",
  "altitude",
  "frequency",
  "dataRate",
  "adr",
  "codeRate",
  "modulation",
  "bandwidth",
  "spreadFactor"
]


Expression:  **.$keys()[0]

Result:

[
  "applicationID",
  "mac",
  "frequency",
  "modulation"
]


Expression:  **.$keys()[1]

Result:

[
  "applicationName",
  "rssi",
  "dataRate",
  "bandwidth"
]



Expression:  **.$keys()[2]

Result:

[
  "deviceName",
  "loRaSNR",
  "adr",
  "spreadFactor"
]



Expression:  **.$keys()[14]

Result:

** no match **



Expression:  (**.$keys())[14]

Result:

"latitude"



Expression:  (**.$keys())[[14..18]]

Result:

[
  "latitude",
  "longitude",
  "altitude",
  "frequency",
  "dataRate"
]










No comments: