Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fabioricali/json-success-response

A standard JSON API response
https://github.com/fabioricali/json-success-response

java javascript json json-api json-response json-schema nodejs php python response

Last synced: 15 days ago
JSON representation

A standard JSON API response

Awesome Lists containing this project

README

        


JSON Success Response


My JSON API standard response which can also be yours.







Param|Type|Description
-|-|-
success|boolean| true if ok, false if error
code|number| server status code
message|string| server message
result|string, number, boolean, array, object, null| response result
time|string| response time in ISO standard

### Example
#### Response ok
```
HTTP/1.1 200 OK
Content-Type: application/json
```
```json
{
"success": true,
"code": 200,
"message": "OK",
"result": 123,
"time": "2017-08-30T09:59:00.846Z"
}
```
#### Response error
```
HTTP/1.1 401 Unauthorized
Content-Type: application/json
```
```json
{
"success": false,
"code": 401,
"message": "Unauthorized",
"result": null,
"time": "2017-08-30T09:59:00.846Z"
}
```

### Author
Fabio Ricali

### License
MIT