praveenchappa has asked for the wisdom of the Perl Monks concerning the following question:
hi, i am generating a json file which will have all possible cases that a json object could hold and i want the object to be as large as 64kb and i am manually appending and forming the json object,but to validate the formed string i used from_json($string), i am getting the errors i could not find where the error occurs,please help me
sub json() { my $obj="["; my $n=20; for(my $i=0;$i<$n;$i++) { $obj.="{ \"id\":\"stu_$i\", "; $obj.="\"is Active\":true,\"name\":\"studentname$i\","; $obj.="\"address\":".getaddr(); $obj.="\"qualifications\":".getqualifications(); my $k=int(rand(20))+20; $obj.="\"age\":$k,"; $obj.="\"gender\":\"male\","; $obj.="\"email\":".getemail(); $obj.="\"about\":".getabout(); $obj.="\"rgistered\":\"".localtime()."\","; $obj.="\"phone\":".getphone(); $obj.=getstandctry(); $obj.="\"subjects\":".getsubjects().","; $obj.="\"subjects2\":".getsubjects(); $obj.="},"; } chop($obj) if $obj=~ m(,$); #if (is_json_valid($obj)) # { # print " ... do something ..."; # } my $data_structure = from_json($obj); print Dumper($data_structure) ; writetofile($data_structure); }
error: , or ] expected while parsing array, at character offset 658656 (before "(end of string)") at C:/Strawberry/perl/vendor/lib/JSON.pm line 168. Press any key to continue . . .
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need help in validating json
by Loops (Curate) on Oct 27, 2014 at 07:23 UTC | |
|
Re: need help in validating json
by poj (Abbot) on Oct 27, 2014 at 08:21 UTC | |
| |
|
Re: need help in validating json
by Corion (Patriarch) on Oct 27, 2014 at 08:06 UTC | |
|
Re: need help in validating json
by Anonymous Monk on Oct 27, 2014 at 07:16 UTC | |
|
Re: need help in validating json
by Random_Walk (Prior) on Oct 27, 2014 at 11:07 UTC |