MCPcopy Index your code
hub / github.com/expressjs/body-parser / json

Function json

lib/types/json.js:48–62  ·  view source on GitHub ↗

* Create a middleware to parse JSON bodies. * * @param {Object} [options] * @returns {Function} * @public

(options)

Source from the content-addressed store, hash-verified

46 * @public
47 */
48function json (options) {
49 const normalizedOptions = normalizeOptions(options, 'application/json')
50
51 const parse = createJsonParser(options)
52
53 const readOptions = {
54 ...normalizedOptions,
55 // assert charset per RFC 7159 sec 8.1
56 isValidCharset: (charset) => charset.slice(0, 4) === 'utf-'
57 }
58
59 return function jsonParser (req, res, next) {
60 read(req, res, next, parse, debug, readOptions)
61 }
62}
63
64/**
65 * Create a JSON parse function

Callers

nothing calls this directly

Calls 3

normalizeOptionsFunction · 0.85
createJsonParserFunction · 0.85
readFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…