Skip to content

Parsing a dubious JavaScript/JSON file #292

@cormullion

Description

@cormullion

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! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions