swjin

json example

...@@ -14,6 +14,14 @@ app.get('/book/:bookId', function (req, res) { ...@@ -14,6 +14,14 @@ app.get('/book/:bookId', function (req, res) {
14 res.send(books[bookId]); 14 res.send(books[bookId]);
15 }); 15 });
16 16
17 +/*
18 +{
19 + "id" : 2,
20 + "name" : "book2",
21 + "price" : 2000,
22 + "author" : "jin"
23 +}
24 +*/
17 app.post('/book', function (req, res) { 25 app.post('/book', function (req, res) {
18 // Create book information 26 // Create book information
19 books[req.body.id] = [req.body.id, req.body.name, req.body.price, req.body.author]; 27 books[req.body.id] = [req.body.id, req.body.name, req.body.price, req.body.author];
...@@ -28,7 +36,7 @@ app.put('/book/:bookId', function (req, res) { ...@@ -28,7 +36,7 @@ app.put('/book/:bookId', function (req, res) {
28 36
29 app.delete('/book/:bookId', function (req, res) { 37 app.delete('/book/:bookId', function (req, res) {
30 // Delete book information 38 // Delete book information
31 - 39 +
32 }) 40 })
33 var server = app.listen(80); 41 var server = app.listen(80);
34 console.log(books); 42 console.log(books);
......