Parsing ArduinoThing as JSON data

Hi All,

I am using python3 and trying to parse the data which is returned from api_response.

api_response = api.things_v2_show(id='xxxxxx-xxxx-xxxx-xxxxxxxxxxx')

This provides the data which I am attempting to parse. If I print this, it is in a JSON format. If I type the data it says "<class 'iot_api_client.models.arduino_thing.ArduinoThing'>"

My challenge is if i try json.dumps(api_response) I get an error message saying:

File "/home/user/", line 52, in <module>
final_dict = json.dumps(api_response)
File "/usr/lib/python3.9/json/", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.9/json/", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.9/json/", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.9/json/", line 179, in default
raise TypeError(f'Object of type {} '
TypeError: Object of type ArduinoThing is not JSON serializable

The Key seems to be this: TypeError: Object of type ArduinoThing is not JSON serializable

I am at a loss. I am simply trying to extract the following. I can painfully iterate over this with regex, but it seems like there must be a simpler method. Any help is greatly appreciated. I can't figure out how to get these values.

             'last_value': 87.23750305175781,
             'name': 'PlatformTemp',
             'value_updated_at': datetime.datetime(2021, 8, 9, 22, 34, 34, 999000, tzinfo=tzlocal()),
             'variable_name': 'platformTemp'}],

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.