JSON.jl icon indicating copy to clipboard operation
JSON.jl copied to clipboard

Parsing a dubious JavaScript/JSON file

Open cormullion opened this issue 4 years ago • 2 comments

I was deep in a rabbit hole trying to parse a JavaScript file that defined a JSON object. I found an easy way to reproduce it on a mac:

using LazyJSON, JSON
s = read("/Applications/Julia-1.1.app/Contents/Resources/julia/share/doc/julia/html/en/search_index.js", String)
s = replace(s, "var documenterSearchIndex =" => "" )
jsoncontents1 = LazyJSON.parse(s)
jsoncontents2 = JSON.parse(s)

JSON.jl complains about a backslashed ':

ERROR: LoadError: Invalid escape sequence
Line: 15
Around: ...se Julia\'s compiler is differ...

I thought at first that this may well be the correct thing to do. But when I tried LazyJSON, it parsed without errors, which made me think that it might be OK. I spent a few minutes searching the internet but couldn't work out whether a \' was OK or not...

So I'll let you decide if this is a bug! :)

cormullion avatar Sep 17 '19 09:09 cormullion