json-parse-bigint
Version:
convert all the big integers to string in JSON before JSON.parse
1 lines • 380 B
JavaScript
var JsonParseBigInt=(function(){var jsonParse=JSON.parse;return function parse(str,reviver){if(/\d{16,}/.test(str)){str=str.replace(/"(\\?[\s\S])*?"|([+\-\d.eE]{16,})/g,function(match,_,num){if(num&&/^\d{16,}$/.test(num)){return'"'+match+'"'}return match})}return jsonParse(str,reviver)}})();if(typeof module!=="undefined"&&module&&module.exports){module.exports=JsonParseBigInt};