I am looking for a way of parsing real JavaScript object data (which, for a number of reasons, doesn't conform to the JSON standard) from within Perl.
I have found that the JSON module, does a fair job if the allow_singlequote and allow_barekey options are enabled, but I am still having problems parsing single-quoted values that contain escaped single quotes and unescaped double quotes. For instance,
{ label : 'can\'t process' }
and
{ label : '"bad" character' }
throw
illegal backslash escape sequence in string
and
invalid character encountered while parsing JSON string
respectively, because the module requires only the standard set of characters to be escaped, regardless of the containing quotes.
I thought I had found something that would work in the JSON::DWIW module, but it hasn't been updated since 2010 and I can't get it to install.
My only answer so far is to install a full-blown JavaScript engine using JavaScript, and run the string as JavaScript code. This works fine, but is far from straightforward and is very much overkill for what I want.
Does anyone have any suggestions for alternatives that I could try?