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 . . .
In reply to need help in validating json by praveenchappa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |