Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Quick 'n dirty extraction of JSON from an HTML page

by tobyink (Canon)
on Mar 09, 2021 at 14:29 UTC ( #11129374=note: print w/replies, xml ) Need Help??


in reply to Re^2: Quick 'n dirty extraction of JSON from an HTML page
in thread Quick 'n dirty extraction of JSON from an HTML page

Consider using the original regexp, which doesn't require keys to be quoted, and parsing the JSON using Cpanel::JSON::XS and turning relaxed mode.

Javascript objects can of course still include values which cannot be encoded into JSON, for example:

var obj = { "some_key": Date.now(), "other_key": function () { console.log("Hello world"); } };

So if your Javascript objects contain things like this, you'll be out of luck. You might want to wrap your JSON decoding in try/catch or eval.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129374]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2021-10-27 14:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (93 votes). Check out past polls.

    Notices?