I'm trying to run jsonlint
on a 40MB JSON file, but it halts execution with an exit status of 5
, and the following error message:
FATAL ERROR: JS Allocation Failed - process out of memory
Does anyone know how I can get this JSON pretty-printed? I wonder if it has to do with node's --max-old-space-size
argument, but I'm also unsure how to pass this to the installed executable file.
If there's another approach I could take to rendering this with human-readable indentation, I'd appreciate those suggestions, too.
jsonlint is based on Jison, that's a parser generator. It's simple to write, but it's extremely slow. So just don't use that unless you really need some of it's features (like sorting object keys).
If you want to pretty-print JSON, either use built-in -
JSON.stringify(object, '\t')
, or jju module -require('jju').stringify(object, {mode: 'json'})
for more compact, but still human-readable representation.40MB will result to about 200-300MB of space, which is definitely not that big.