Open MagnusLii opened 7 months ago
def decodeStringToJSON(json_string):
try:
decodedMessage = json.loads(json_string)
print('JSON test passed.')
return decodedMessage
except json.decoder.JSONDecodeError as error:
print(f'JSON test failed. Error: {error}')
return -1
String decode function
Goal
The objective is to create a function that takes in a string from a MQTT message and tries to convert said string into a JSON object. The function should not modify the original string.
Arguments
Returns
Name of function
decodeStringToJSON