prettyjson
prettyjson copied to clipboard
Error parcing large file with only one row(40Mb json file)
When I try to do it from cli
Error: File 'messages.json' does not exist
When I try to do it from node
directory/node_modules/prettyjson/lib/prettyjson.js:167
output.push.apply(
^
RangeError: Maximum call stack size exceeded
at directory/prettyjson/lib/prettyjson.js:167:19
at Array.forEach (<anonymous>)
at renderToArray (directory/node_modules/prettyjson/lib/prettyjson.js:145:36)
at Object.render (directory/node_modules/prettyjson/lib/prettyjson.js:210:10)
at Object.<anonymous> (directory/test.js:14:24)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
Here is a test case to reproduce the issue:
it('should not trigger maximum call stack size exceeded error', function () {
const subject = {
data: []
};
let index = 1000000;
while (index--) {
subject.data.push(index);
}
prettyjson.render(subject);
});
The solution would be to rewrite renderToArray to use a loop instead of recursion.
@rafeca Any chance of fixing this issue?