How to convert ListResponse to JSON?

Hello everyone,
I am using python SDK for Nylas and when retrieving all emails for a grant_id with

nylas.messages.list

I get a ListResponse. I however would like to serve the response as an API so ideally I’d like to convert this in json.

I’ve found out that we can do something like this

messages_data = messages.data
response = [el.__dict__ for el in messages_data]

but I don’t know if Nylas has something natively that would work better.

Hello @gpapidas if you perform a cURL call, then the response is going to be on JSON format. With the SDK, the return formatted data to make it easier for developers to handle the information as you can for example write:

messages_data = messages.data
print(messages_data[0].body)

Besides the option you’re using, I don’t think we have anything native to return the information back to JSON.

1 Like