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.


In reply to JSON decode problem by vlad.goshko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.