Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

## So how does it work?
A basic JSend-compliant response is as simple as this:
```
```json
{
status : "success",
data : {
"status" : "success",
"data" : {
"post" : { "id" : 1, "title" : "A blog post", "body" : "Some useful content" }
}
}
Expand All @@ -29,10 +29,10 @@ When setting up a JSON API, you'll have all kinds of different types of calls an
### Success ###
When an API call is successful, the JSend object is used as a simple envelope for the results, using the data key, as in the following:
#### GET /posts.json: ####
```
```json
{
status : "success",
data : {
"status" : "success",
"data" : {
"posts" : [
{ "id" : 1, "title" : "A blog post", "body" : "Some useful content" },
{ "id" : 2, "title" : "Another blog post", "body" : "More content" },
Expand All @@ -41,17 +41,17 @@ When an API call is successful, the JSend object is used as a simple envelope fo
}
```
#### GET /posts/2.json: ####
```
```json
{
status : "success",
data : { "post" : { "id" : 2, "title" : "Another blog post", "body" : "More content" }}
"status" : "success",
"data" : { "post" : { "id" : 2, "title" : "Another blog post", "body" : "More content" }}
}
```
#### DELETE /posts/2.json: ####
```
```json
{
status : "success",
data : null
"status" : "success",
"data" : null
}
```
Required keys:
Expand All @@ -62,7 +62,7 @@ Required keys:
### Fail ###
When an API call is rejected due to invalid data or call conditions, the JSend object's data key contains an object explaining what went wrong, typically a hash of validation errors. For example:
#### POST /posts.json (with data body: "Trying to creating a blog post"): ####
```
```json
{
"status" : "fail",
"data" : { "title" : "A title is required" }
Expand All @@ -76,7 +76,7 @@ Required keys:
### Error ###
When an API call fails due to an error on the server. For example:
#### GET /posts.json: ####
```
```json
{
"status" : "error",
"message" : "Unable to communicate with database"
Expand Down