Code Monkey home page Code Monkey logo

Comments (4)

peterdudfield avatar peterdudfield commented on May 31, 2024

hmmm, im not quite sure how to do that.

I have a 'geoDataFrame' and i use to_json to put it to a json object.

Admittedly, all respsonse need response.json() to get the object.

Is json normally a string, but just the string is ~ like a dictionary - https://www.w3schools.com/python/python_json.asp

from uk-pv-national-gsp-api.

flowirtz avatar flowirtz commented on May 31, 2024

I just had another look.

So currently the endpoint for the GSP shapes returns this:

"{\"key\": \"value\"}"

But typically, with REST APIs, it would be good to return the JSON directly, instead of the string escaped version, ie

{"key": "value"}

geopandas.GeoDataFrame.to_json seems to return the JSON as string, as per the docs. I'd suggest that instead we try to return the dict directly, ie

to_json() -> to_dict()

https://github.com/openclimatefix/nowcasting_api/blob/96d8e46608e4ac9edcfea38918165ea41e43f3da/src/main.py#L92

According to FastAPIs docs, they would convert that dict into JSON automatically.

I wasn't able to get the API running locally, so I couldn't try it myself yet.

from uk-pv-national-gsp-api.

peterdudfield avatar peterdudfield commented on May 31, 2024

Cool ill do this - thanks for looking into this @flowirtz.

Im interested what error you got when you ran it locally?

from uk-pv-national-gsp-api.

flowirtz avatar flowirtz commented on May 31, 2024

Fantastic, thanks so much, Peter! I don't remember anymore tbh, but I'll try running it again later this week and debug together with you :)

from uk-pv-national-gsp-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.