2 var jju = require('../')
4 // this function registers json5 extension, so you
5 // can do `require("./config.json5")` kind of thing
6 module.exports.register = function() {
7 var r = require, e = 'extensions'
8 r[e]['.json5'] = function(m, f) {
10 m.exports = jju.parse(FS.readFileSync(f, 'utf8'))
14 // this function monkey-patches JSON.parse, so it
15 // will return an exact position of error in case
17 module.exports.patch_JSON_parse = function() {
18 var _parse = JSON.parse
19 JSON.parse = function(text, rev) {
21 return _parse(text, rev)
23 // this call should always throw
24 require('jju').parse(text, {
28 reserved_keys: 'replace',
29 null_prototype: false,
32 // if it didn't throw, but original parser did,
33 // this is an error in this library and should be reported
39 // this function is an express/connect middleware
40 // that accepts uploads in application/json5 format
41 module.exports.middleware = function() {
42 return function(req, res, next) {
43 throw Error('this function is removed, use express-json5 instead')