josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
814 stars 108 forks source link

Error not displayed when only "" is entered #414

Closed zehawki closed 3 months ago

zehawki commented 3 months ago

No error alert is displayed when only "" is entered in the editor. Surely this is not valid json, or?

image

Similar this [""] also doesnt give an error.

josdejong commented 3 months ago

An empty string "" is indeed valid JSON.

josdejong commented 3 months ago

Maybe you're confusing an empty string vs a string containing an empty string?

JSON.parse('')   // Error
JSON.parse('""') // Returns the parsed, empty string ''