Fixed json parsing
This commit is contained in:
parent
da760ffbe6
commit
3ddb126858
@ -168,9 +168,7 @@ class MeshtasticMQTT(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Convert to JSON and handle NaN values in one shot
|
# Convert to JSON and handle NaN values in one shot
|
||||||
json_packet = json.loads(MessageToJson(mp, including_default_value_fields=True,
|
json_packet = json.loads(MessageToJson(mp))
|
||||||
preserving_proto_field_name=True,
|
|
||||||
float_precision=10))
|
|
||||||
|
|
||||||
# Replace all NaN values with null before any further processing
|
# Replace all NaN values with null before any further processing
|
||||||
def replace_nan(obj):
|
def replace_nan(obj):
|
||||||
@ -292,8 +290,7 @@ class MeshtasticMQTT(object):
|
|||||||
elif mp.decoded.portnum == portnums_pb2.TELEMETRY_APP:
|
elif mp.decoded.portnum == portnums_pb2.TELEMETRY_APP:
|
||||||
telemetry = telemetry_pb2.Telemetry()
|
telemetry = telemetry_pb2.Telemetry()
|
||||||
telemetry.ParseFromString(mp.decoded.payload)
|
telemetry.ParseFromString(mp.decoded.payload)
|
||||||
telemetry_json = json.loads(MessageToJson(telemetry))
|
json_packet['decoded']['payload'] = json.loads(MessageToJson(telemetry))
|
||||||
json_packet['decoded']['payload'] = replace_nan(telemetry_json)
|
|
||||||
print(json.dumps(json_packet))
|
print(json.dumps(json_packet))
|
||||||
|
|
||||||
elif mp.decoded.portnum == portnums_pb2.TEXT_MESSAGE_APP:
|
elif mp.decoded.portnum == portnums_pb2.TEXT_MESSAGE_APP:
|
||||||
|
Loading…
Reference in New Issue
Block a user