jsonpointer-http

1.0.8 • Public • Published

jsonpointer-http

HTTP routes on top of [RFC6901]

or simpler..

HTTP routes on top of JSON documents

Use

Consider the following JSON:

var data = {
  people: [{
    name: 'Nicola',
    surname: 'Greco'
  }, ..]
}

Using this module, you can navigate the JSON like it was a path. For example:

GET http://example.com/people/1
{
  name: 'Nicola',
  surname: 'Greco'
}
GET http://example.com/people/1/name
'Nicola'

and also PUT

$ curl -X PUT -d 'Virginia' http://example.com/people/1/name
// will set the name to be Virginia
$ curl -H 'Accept: application/json' -X PUT -d '{"name": "Virginia"}' http://example.com/people/1
// will set the name to be Virginia

Install

$ npm install --save jsonpointer-http

Use it

var router = require('jsonpointer-http')
var http = require('http')
var server = http.createServer(router({your: json: {'here'}}))
server.listen(8080)

License

MIT

Dependents (1)

Package Sidebar

Install

npm i jsonpointer-http

Weekly Downloads

0

Version

1.0.8

License

MIT

Last publish

Collaborators

  • nicola