Hi All, I am running a perl script which uses JSON module. Below is script part which is doing the decoding

 my $data = decode_json $line;

Now while running this script I am getting the below error

File2: VSCDR_0001_00150_20150721-102225.json ':' expected, at character offset 193 (before "@serialNumber":"4000... +") at /root/reportscr/scripts/vs_state_change_dr_UW.pl line 103

Now as the error suggested line 193 of json file VSCDR_0001_00150_20150721-102225.json contains the error. Below are part of json file from line no. 191 to 195. (middle record is record no- 193).

{"@serialNumber":"235665321979", "@timestamp":"20150721T10:22:59+0530" +, "@subscriberId":"7409808075", "@transactionId":"394345856161456", " +@operatorId":"", "@voucherGroup":"B9", "@expiryDate":"20160731T23:59: +59+0530", "@state":"RESERVED", "@reserveTimeoutResolution":"PENDING", + "@subState":"", "@serviceType":"RESERVE_RECORD", "@value":"1554", "@ +agent":"", "@batchId":"10003"} {"@serialNumber":"235665321979", "@timestamp":"20150721T10:22:59+0530" +, "@subscriberId":"7409808075", "@transactionId":"394345856161456", " +@operatorId":"", "@voucherGroup":"B9", "@expiryDate":"20160731T23:59: +59+0530", "@state":"USED", "@reserveTimeoutResolution":"", "@subState +":"", "@serviceType":"COMMIT_RECORD", "@value":"1554", "@agent":"", " +@batchId":"10003"} {"@serialNumber":"400003262400", "@timestamp":"20150721T10:22:59+0530" +, "@subscriberId":"9675312531", "@transactionId":"442230856161952", " +@operatorId":"", "@voucherGroup":"A9", "@expiryDate":"20160817T23:59: +59+0530", "@state":"RESERVED", "@reserveTimeoutResolution":"PENDING", + "@subState":"", "@serviceType":"RESERVE_RECORD", "@value":"777", "@a +gent":"", "@batchId":"RC_10"} {"@serialNumber":"400003262400", "@timestamp":"20150721T10:22:59+0530" +, "@subscriberId":"9675312531", "@transactionId":"442230856161952", " +@operatorId":"", "@voucherGroup":"A9", "@expiryDate":"20160817T23:59: +59+0530", "@state":"USED", "@reserveTimeoutResolution":"", "@subState +":"", "@serviceType":"COMMIT_RECORD", "@value":"777", "@agent":"", "@ +batchId":"RC_10"} {"@serialNumber":"235666366547", "@timestamp":"20150721T10:22:59+0530" +, "@subscriberId":"9759261690", "@transactionId":"732696256161800", " +@operatorId":"", "@voucherGroup":"B9", "@expiryDate":"20160731T23:59: +59+0530", "@state":"RESERVED", "@reserveTimeoutResolution":"PENDING", + "@subState":"", "@serviceType":"RESERVE_RECORD", "@value":"1554", "@ +agent":"", "@batchId":"10002"}

This looks like in proper format. I am not able to figure out the problem. Could you please help.


In reply to Perl script not working with JSON module by Ankur_kuls

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.