- def on_message(client, userdata, msg):
- print(msg.topic+" " + ":" + str(msg.payload))
- print(type(msg.payload))
- print(json.loads(msg.payload.decode('utf8')))
- print(type(json.loads(msg.payload.decode('utf8'))))
- js_code = json.loads(msg.payload.decode('utf8'))
- print(js_code);
-
- if "name" in js_code :
- print(js_code["name"]);
- elif "gateway_id" in js_code :
- print(js_code["gateway_id"]);
- print(js_code["funcode"]);
- print(js_code["device_id"]);
- print(js_code["value"]);
- else :
- print("dict error");