项目作者: tdmalone

项目描述 :
Parses input in either application/json or application/x-www-form-urlencoded content-types, returning it as an object.
高级语言: JavaScript
项目地址: git://github.com/tdmalone/simple-body-parser.git
创建时间: 2018-03-18T09:38:13Z
项目社区:https://github.com/tdmalone/simple-body-parser

开源协议:MIT License

下载


Simple Body Parser

Parses input in either application/json or application/x-www-form-urlencoded content-types, returning it as an object.

Usage

Install with Yarn:

  1. yarn add @tdmalone/simple-body-parser

Or with npm:

  1. npm install @tdmalone/simple-body-parser

Then, pass strings and get an object back:

  1. const parse = require( '@tdmalone/simple-body-parser' );
  2. const body = '{"some":"data"}';
  3. const data = parse( body, 'application/json' );
  4. console.log( data );

Ideally, you’d use this while parsing input from some source where the content-type is provided as a header.

Tests

Coming soon via Jest. Runnable with yarn test.

License

MIT.