text: 'use strict';
  
  var errorEx = require('error-ex');
  var fallback = require('json-parse-better-errors');
  
  var JSONError = errorEx('JSONError', {
  	fileName: errorEx.append('in %s')
  });
  
  module.exports = function (input, reviver, filename) {
  	if (typeof reviver === 'string') {
  		filename = reviver;
  		reviver = null;
  	}
  
  	try {
  		try {
  			return JSON.parse(input, reviver);
  		} catch (err) {
  			fallback(input, reviver);
  
  			throw err;
  		}
  	} catch (err) {
  		err.message = err.message.replace(/\n/g, '');
  
  		var jsonErr = new JSONError(err);
  		if (filename) {
  			jsonErr.fileName = filename;
  		}
  
  		throw jsonErr;
  	}
  };