Many web services involve a request to create a new persistent object or make an update to an existing persistent object. In order to do these kinds of operation, the application will need input from the client.
A RESTful web service will generally accept input (and produce output) in the form of JSON documents. For more information on JSON, see the Reading JSON documents recipe in Chapter 8, Input/Output, Physical Format, and Logical Layout
How can we parse JSON inputs from web clients? What's an easy way to validate the input?
We'll extend the Flask application from the Parsing the query string in a request recipe to add a user registration feature; this will add a player who can then request cards. The player is a resource that will involve the essential CRUD operations:
- A client can do a
POST
to the/players
path to create a new player. This will include a payload of a document that describes the player. The service will validate the document, and if it...