bhollis/jsonview

Unable to parse valid JSON

Closed this issue · 8 comments

I have a valid JSON string (according to RFC 4627, RFC 7159, ECMA-404):

{"code":0,"message":"OK","result":[{"fund_id":2,"fund_mnemo":"BAIKAL","fund_name":"\u041e\u0410\u041e \u0410\u041a \"\u0411\u0430\u0439\u043a\u0430\u043b\u0411\u0430\u043d\u043a\" ","allow":true,"answer":"\u041d\u0435\u0442 API \u0444\u043e\u043d\u0434\u0430"},{"fund_id":4,"fund_mnemo":null,"fund_name":"\u041f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u043e\u043d\u0434","allow":true,"answer":"\u041d\u0435\u0442 API \u0444\u043e\u043d\u0434\u0430"}],"cached":false}

but mozilla extension says

bad Unicode escape at line 1 column 126 and shows raw string without formatting.

Any other parsers can parse it, tested at:
https://jsonformatter.curiousconcept.com/
http://codebeautify.org/jsonviewer
http://www.jsoneditoronline.org/

I'm seeing false parsing errors as well, seems to be an interesting combination of escaped values and numbers.
JSONView 1.2.2 c/o Firefox

Simple snippet to reproduce:

{
    "precondition": "text that ends in an escaped backslash \\",
    "errorline": "After the number, the parser complains: 3 here is the error"
}

expected ',' or '}' after property value in object at line 3 column 61

@Aleksandr-ru if I open your string with JSONView it doesn't complain, though.

(edit: typo)

Potentially the same problem. Parse is failing on:

{
   "key":"\"value\u201d"
}

Thanks for all the examples! I should be able to bang out a fix pretty quick.

@alpha0010 that example works for me with JSONView 1.2.2.

@Aleksandr-ru your example also works in JSONView 1.2.2.

@elgrafico your problem was a bug caused by a really stupid typo. I'll push JSONView 1.2.3 soon.

Not sure why mine was not worker before then... but in any case, it works now. Thanks for the fast response.