vlad.goshko has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks, I have question about json decoding. I need to deserialize invalid json, but I dont know how. Here is what I got, sample from page:
... is_touch: ('ontouchstart' in window), repository_urls: ["publisher_view2_videossp/PublisherView_videossp2"], origin_repository_url: "publisher_view2_videossp/PublisherView_videoss +p2", workbook_repo_url: "publisher_view2_videossp", publish_date: new Date(1431654084199), tabs_allowed: false, showTabsWorkbook: true, mobile_app_cookie: "", current_project_id: "7", current_sheet_name: "", current_sheet_type: "", current_workbook_name: "publisher_view2_videossp", current_workbook_id: "1548", current_view_id: "2713", sheetId: "PublisherView_videossp2", showParams: "{"revertType":null,"refresh":false,"checkpoint":false,"sh +eetName":"","unknownParams":"zone_id=6290&ac=a9aef098062f9646bd1638d0 +c6054c7b&account_id=62&Start_Date=2016-07-27&End_Date=2016-08-03","la +youtId":""}", stickySessionKey: "{"isAuthoring":false,"lastUpdatedAt":1470316180805, +"workbookId":1548}", ...
I'm using JSON::PP module to decode with maximum loose decoding, like this:
$res = JSON::PP->new->relaxed->allow_singlequote->allow_barekey->loose +->decode($data);
But I have troubles with fields like this:
is_touch: ('ontouchstart' in window),And this:
publish_date: new Date(1431654084199),And this:
showParams: "{"revertType":null,"refresh":false,"checkpoint":false,"sh +eetName":"","unknownParams":"zone_id=6290&ac=a9aef098062f9646bd1638d0 +c6054c7b&account_id=62&Start_Date=2016-07-27&End_Date=2016-08-03","la +youtId":""}",
It throws error: malformed JSON string, and its understood.
So question is: what can I do to filter lines like this? Json content that I receive is dynamic, so hardcoding this lines wont affect.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: JSON decode problem
by Corion (Patriarch) on Aug 04, 2016 at 14:51 UTC | |
|
Re: JSON decode problem
by kennethk (Abbot) on Aug 04, 2016 at 15:59 UTC | |
|
Re: JSON decode problem
by FreeBeerReekingMonk (Deacon) on Aug 05, 2016 at 13:20 UTC | |
by kennethk (Abbot) on Aug 05, 2016 at 15:14 UTC | |
by FreeBeerReekingMonk (Deacon) on Aug 11, 2016 at 21:16 UTC | |
by kennethk (Abbot) on Aug 15, 2016 at 15:45 UTC | |
|
Re: JSON decode problem
by FreeBeerReekingMonk (Deacon) on Aug 11, 2016 at 21:38 UTC |