Solutions
1. Set Json-lib to filter out the fields that cause loops.
Java code
Copy Code code as follows:
Jsonconfig config = new Jsonconfig ();
Config.setignoredefaultexcludes (FALSE);
Config.setcycledetectionstrategy (cycledetectionstrategy.lenient);
Config.registerjsonvalueprocessor (date.class,new datejsonvalueprocessor ("Yyyy-mm-dd")); Date Processor Register
Config.setexcludes (new string[]{//just set this array to specify which fields to filter.)
"Consignee",
"Contract",
"Coalinfo",
"Coaltype",
"Startstation",
"Balanceman",
"Endstation"
});
String tempstr = "{\" totalrecords\ ":" + total.tostring () + ", \ datas\": "+jsonserializer.tojson (List,config). ToString ( )+"}";
Out.print (TEMPSTR);
Jsonconfig config = new Jsonconfig ();
Config.setignoredefaultexcludes (FALSE);
Config.setcycledetectionstrategy (cycledetectionstrategy.lenient);
Config.registerjsonvalueprocessor (date.class,new datejsonvalueprocessor ("Yyyy-mm-dd")); Date Processor Register
Config.setexcludes (new string[]{//just set this array to specify which fields to filter.) "Consignee", "contract", "Coalinfo", "Coaltype", "Startstation", "Balanceman", "endstation"}); String tempstr = "{\" totalrecords\ ":" + total.tostring () + ", \ datas\": "+jsonserializer.tojson (List,config). ToString ( )+"}"; Out.print (TEMPSTR);
2. Set the Json-lib Setcycledetectionstrategy property to handle the loop itself, but the data is too complex to cause data overflow or inefficiency.
Java code
[Code]
Jsonconfig config = new Jsonconfig ();
Config.setignoredefaultexcludes (FALSE);
Config.setcycledetectionstrategy (cycledetectionstrategy.lenient);
Config.registerjsonvalueprocessor (date.class,new datejsonvalueprocessor ("Yyyy-mm-dd")); Date Processor Register
String tempstr = "{\" totalrecords\ ":" + total.tostring () + ", \ datas\": "+jsonserializer.tojson (List,config). ToString ( )+"}";
Out.print (TEMPSTR);