The issue you're facing with jsbeautifier creating invalid JSON is indeed a known bug, as you've noted. Unfortunately, there’s no direct fix within the library itself right now.
Workarounds:
- Use Python’s Built-in JSON Tools Python’s json module can format your data correctly and always outputs valid JSON. This can be a more reliable alternative to jsbeautifier.
- Post-process the Output If you need to stick with jsbeautifier, you can clean up the output by removing the extra spaces between the minus sign and the number using a simple text-processing step.
- Use an Online Formatter For a quick and easy solution, try a JSON Formatter. It ensures your JSON is both valid and properly formatted without the risk of errors like this. It’s especially handy when dealing with complex JSON structures.