Deep Dive into Flask Marshmallow

The reasons to use Flask Marshmallow:

Validate input data. Deserialize input data to app-level objects. Serialize app-level objects to primitive Python types. The serialized objects can then be rendered to standard formats such as JSON for use in an HTTP API.

Nick Janetakis describes it all in straightforward terms:

Basically, it handles converting JSON to and from SQLAlchemy or Python objects. For example, we can’t just send a raw SQLAlchemy row over HTTP. Instead we first convert it to JSON, and then send that JSON as a response. That’s the main purpose of this library. It also lets us set up these things called schemas. They help us white list and validate input. For example, if one of our fields needs to be a string in between 2 and 200 characters long, we can set that up in our schema. If it happens to fail the validation then it will return an error with a friendly message. You can sort of compare Marshmallow’s validation to the WTForms library.