From 4f9f1fa9c8de1deae3f163d838f6a3dfe0ba09ec Mon Sep 17 00:00:00 2001 From: Guilherme Berger Date: Thu, 26 Dec 2013 19:02:21 -0200 Subject: [PATCH] Update README.md, fixing examples with bad JSON The examples given in the README do not conform to the JSON specification. In fact, when run in the way shown, it doesn't even work. This commit fixes the formatting issues in the JSONs. They are mostly wrapping attribute names in quotes, and changing single quotes to double quotes. I also made those changed to JS objects that wasn't specifically JSON, but would be nice to be formatted like JSON in case someone wants to copy the example and paste it into a .json file. --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b70a543..dc8f9d0 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Created with :heart: for front-end developers who need a flexible back-end for q ```bash $ cat db.json { - posts: [ - { id: 1, body: 'foo' } + "posts": [ + { "id": 1, "body": "foo" } ] } $ json-server --file db.json @@ -29,9 +29,9 @@ $ curl -i http://localhost:3000/posts/1 ```javascript var server = require('json-server'); -var db = { - posts: [ - {id: 1, body: 'foo'} +var db = { + "posts": [ + { "id": 1, "body": "foo" } ] } @@ -97,13 +97,13 @@ Here's 2 examples showing how to format JSON or JS seed file: ```javascript { - posts: [ - { id: 1, body: 'foo'}, - { id: 2, body: 'bar'} + "posts": [ + { "id": 1, "body": "foo"}, + { "id": 2, "body": "bar"} ], - comments: [ - { id: 1, body: 'baz', postId: 1} - { id: 2, body: 'qux', postId: 2} + "comments": [ + { "id": 1, "body": "baz", "postId": 1} + { "id": 2, "body": "qux", "postId": 2} ] } ``` @@ -115,7 +115,7 @@ exports.run = function() { var data = {}; data.posts = []; - data.posts.push({id: 1, body: 'foo'}); + data.posts.push({"id": 1, "body": "foo"}); //... return data;