Skip to content

Instantly share code, notes, and snippets.

@xgqfrms-GitHub
Last active June 8, 2017 17:23
Show Gist options
  • Save xgqfrms-GitHub/ddcbbac745c559d23da5e0a39b72220c to your computer and use it in GitHub Desktop.
Save xgqfrms-GitHub/ddcbbac745c559d23da5e0a39b72220c to your computer and use it in GitHub Desktop.
json-server

json-server

https://github.com/typicode/json-server/

https://gist.github.com/xgqfrms-GitHub/950a2682f96c0a64ca81e13de15f16d1

{
  "name": "react-json-server",
  "version": "17.5.16",
  "description": "json server for React faker data!",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "echo \"dev\" && exit 1",
    "prod": "echo \"prop\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/xgqfrms-GitHub/react-json-server.git"
  },
  "keywords": [
    "react",
    "json-server",
    "faker-data"
  ],
  "author": "xgqfrms, webgeeker",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/xgqfrms-GitHub/react-json-server/issues"
  },
  "homepage": "https://github.com/xgqfrms-GitHub/react-json-server#readme",
  "devDependencies": {
    "json-server": "^0.10.1"
  }
}

faker.js

fake data

https://github.com/ufo-github/faker.js

在Node.js和浏览器中生成大量的假数据

https://gist.github.com/xgqfrms-GitHub/cb8459af5e7db7af107a25615f738ab5

JSON Formatter

https://jsonformatter.curiousconcept.com/

JSONLint

The JSON Validator

http://jsonlint.com/

@xgqfrms-GitHub
Copy link
Author

xgqfrms-GitHub commented May 16, 2017

json placeholder

Fake Online REST API for Testing and Prototyping (powered by JSON Server and lowdb)

假数据在线REST API,用于测试和原型设计 由JSON服务器和lowdb提供支持

https://jsonplaceholder.typicode.com/

// jquery & 在控制台或任何地方(支持CORS和JSONP)运行此代码。
var root = 'https://jsonplaceholder.typicode.com';

$.ajax({
  url: root + '/posts/1',
  method: 'GET'
}).then(function(data) {
  console.log(data);
});

lowdb

lowdb是一个由lodash供电的小型本地JSON数据库(支持Node,浏览器和Electron)

https://github.com/typicode/lowdb

https://github.com/xgqfrms-GitHub/json-server

https://egghead.io/lessons/nodejs-creating-demo-apis-with-json-server#/tab-code

http://nmotw.in/json-server/

http://www.betterpixels.co.uk/projects/2015/05/09/mock-up-your-rest-api-with-json-server/

fetch('http://localhost:3000/tasks/')
  .then(function(response) {
    return response.json()
  }).then(function(json) {
    console.log('parsed json: ', json)
  }).catch(function(ex) {
    console.log('parsing failed: ', ex)
  });
fetch('http://localhost:3000/tasks/', {
  method: 'post',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
       "title":   "Add a blogpost about Angular2",
       "dueDate": "2015-05-23T18:25:43.511Z",
       "done": false
   })
}).then(function(response) {
      return response.json()
    }).then(function(json) {
      console.log('parsed json: ', json)
    }).catch(function(ex) {
      console.log('parsing failed: ', ex)
    });

@xgqfrms-GitHub
Copy link
Author

@xgqfrms-GitHub
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment