Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list to json from response object #2

Closed
serialbandicoot opened this issue Jun 23, 2020 · 4 comments
Closed

list to json from response object #2

serialbandicoot opened this issue Jun 23, 2020 · 4 comments

Comments

@serialbandicoot
Copy link

HI this is a bit of a newbie question.

@app.route('/fn_earnings')
def finnhub_earnings():
    response = fc.company_earnings('TSLA', limit=5)
    return { 'data': response }

I'm trying to return the response object from a flask query as json. I've tried multiple combinations but I can't seem to figure out the solution. All the examples are using print.

Would you please be able to give me some idea of how to coerce the object into an json format.

Many thanks...

@finnhubio
Copy link
Contributor

finnhubio commented Jun 24, 2020

Have you tried [s.to_dict() for s in response] ?

@serialbandicoot
Copy link
Author

Yeah it does work, however I thought the library was more of a wrapper and therefore I would be able to get back a json object a bit easier.

I've had a look at the JS version and this seems to be easier to get a json response out. So I might switch or use fhub as this also has a json option, without the need to dig.

@finnhubio
Copy link
Contributor

@nongdenchet can you help take a look whether it's possible to support JSON conversion for these cases ?

@finnhubio
Copy link
Contributor

This feature is now supported right out of the box. All data is returned in JSON format from 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants