python-jsend-response is a simple implementation of JSend.
JSend is a specification that lays down some rules for how JSON responses from web servers should be formatted. JSend focuses on application-level (as opposed to protocol- or transport-level) messaging which makes it ideal for use in REST-style applications and APIs.:
You'll have all kinds of different types of calls and responses. JSend separates responses into some basic types, and defines required and optional keys for each type:
Type | Description | Required Keys |
---|---|---|
success | All went well, and (usually) some data was returned. | status, data |
failure | There was a problem with the data submitted, or some pre-condition of the API call wasn't satisfied | status, data |
error | An error occurred in processing the request, i.e. an exception was thrown | status, message |