iot:aws:json
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
iot:aws:json [2020/06/11 13:04] – created atolstov | iot:aws:json [2020/06/12 10:05] (current) – ↷ Links adapted because of a move operation atolstov | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | json | + | ==== JSON formatted payload ==== |
+ | It is widely used MQTT payload format JSON. | ||
+ | Let’s write a small script which will use inbuild library to encode any WebHMI register values to JSON formatted strings. | ||
+ | Here is the code example to encode a string type message with Amazon Web Services (AWS) [[https:// | ||
+ | |||
+ | <code lua - AWS_thing_report.lua> | ||
+ | function main (userId) | ||
+ | local decoded = | ||
+ | { | ||
+ | state = | ||
+ | { | ||
+ | reported = | ||
+ | { | ||
+ | timestamp | ||
+ | message | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | encoded = cjson.encode( decoded ) | ||
+ | DEBUG(encoded) | ||
+ | WriteReg(" | ||
+ | end | ||
+ | |||
+ | </ | ||
+ | |||
+ | To check the result of script work let’s check “iot-test” subscribed topic in MQTT.fx. | ||
+ | |||
+ | {{ iot: | ||
+ | |||
+ | //Hint: There is drop-down list with MQTT payload format selector in the lower right corner.// |
iot/aws/json.1591880669.txt.gz · Last modified: 2020/06/11 13:04 by atolstov