decode json

Posted on 2013-10-08
Medium Priority
Last Modified: 2014-05-13
i am doing
    %freeb =  %{$json->decode($fr_blob)};

and it is throwing warnings/messages like

unexpected end of string while parsing JSON string

for some rows ...as it reads the data in a huge file line by line...

in perl can i do something that checks if the string is valid json and not process it if its invalid?
i want to eliminate these messages
Question by:Vlearns
  • 2

Author Comment

ID: 39563872

can someone help with this?

Author Comment

ID: 39564000
how can i run json_decode on a string and if its bad json, then simply continue without barfing or throwing errors
LVL 26

Accepted Solution

arober11 earned 2000 total points
ID: 39589643
Have you had a look at the following Article: Using Perl to preview in a Web Page and convert a JSON document into an Excel workbook ?


  # from file content
  local $/;
  open( my $fh, '<', "$sUploadDir/$sFilename" );
  my $json_text   = <$fh>;
  my $roPasedJson = JSON->new->utf8(1)->decode($json_text);

Open in new window


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question