We all know we can use JSON.parse() to convert the string '{"a":0,"b":"haha"}' to the object {a: 0, b: 'haha'}.
But can we convert the string '{a: 0, b: "haha"}' to the object {a: 0, b: 'haha'}?
I'm writing a web crawler and I need to get the data in the page. But the complete data is not in DOM but in one <script> element. So I got the useful content in the <script> and converted that string (like 'window.Gbanners = [{...}, {...}, {...}, ...];') to a JSON-like string (like '{banners : [...]}'). However, I couldn't parse the "JSON-like" string. Does anyone have a solution?
eval? (and simply get rid of the first and last')eval?window.Gbanners=[];. Then I handled this script string simply andevaled it. Maybe I'm fine with it temporarily? -^_^-