Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by tobyink (Canon)
on Mar 09, 2021 at 14:29 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found