gildas-lormeau / JSONVue

Fork of JSONView for Chromium-based browsers
https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc
Other
1.59k stars 615 forks source link

Support for NaN, -Infinity, Infinity #4

Closed kevinmook closed 2 years ago

kevinmook commented 13 years ago

I know it isn't valid JSON, but some tools output NaN, -Infinity, and Infinity. It would be very helpful if the parser could still pretty-print JSON with these values. Right now the parser fails with "Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['"

Sample JSON to reproduce: {"maxScore":NaN}

gildas-lormeau commented 13 years ago

JSONView relies on native JSON.parse method to parse the text and then pretty print it. If it detects an error during the parsing, it uses JSONLint to parse again the text and find the error. That's why it is so strict. So, accepting invalid values implies to not rely on native JSON.parse method and writing a custom parser (maybe based on JSONLint or Douglas Crockford implementation). It represents some work and I cannot promise I'll have time to add this feature soon.