-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Building Python Microservices with FastAPI
By :
It is easier for FastAPI to process JSON-compatible types such as dict, list, and BaseModel objects because they can be easily converted to JSON by the framework using its default JSON editor. However, there are circumstances in which runtime exceptions are raised when processing BaseModel, data model, or JSON objects containing data. One of the many reasons for this is that these data objects have attributes that are not supported by JSON rules, such as UUID and non-built-in date types. Regardless, using a framework’s module classes, these objects can still be utilized by converting them into JSON-compatible ones.
When it comes to the direct handling of the API operation’s responses, FastAPI has a built-in method that can encode typical model objects to convert them to JSON-compatible types before persisting them to any datastore or passing them to the detail parameter of JSONResponse. This method, jsonable_encoder(), returns...