json-viewer icon indicating copy to clipboard operation
json-viewer copied to clipboard

json-viewer fails to parse JSON

Open jribbens opened this issue 3 years ago • 1 comments

The following JSON file confuses json-viewer, which fails to parse it correctly:

{"foo":"a[\\\"=\"\"]"}

It displays:

{
  "foo": "a[\\\"=\"\"
]"}

and anything else from that point in the file onwards fails to display correctly.

jribbens avatar Jun 20 '21 11:06 jribbens

it seems that a long string of special characters that may or may not be escaped with multiple backslashes confuses this plug-in and causes it to fail. I have encountered this problem with a particularly long regex pattern.

"validate": 
{
 "required": true,
"pattern": "^(([A-Za-z0-9\\-\\_\\.\\;\\ \\\"\\'\\(\\)\\\\!\\?\\*\\,\\.\\^\\*\\+\\=\\{\\}\\/\\[\\]\\\\\\|\\:\\;\\>\\`\\~]|\\r\\n|\\r|\\n)*)$",
"customMessage": "Please check the characters keyed into the description field, ensure symbols are keyed in directly from keyboard.",
"maxLength": 16000
},

what happens is that the arrow to collapse arrays and objects will all be placed in the wrong positions, even where the JSON is rendered correctly.

jacoblimzm avatar Jan 17 '22 04:01 jacoblimzm