Parsing the following JSON with the current version of quick-json:
(java sample: String reportsOutput)
["{\"outputMethod\":\"email\",\"emailAddress\":\"test@test.com\"}","{\"outputMet
hod\":\"ftp\",\"username\":\"\",\"password\":\"\",\"server\":\"\",\"port\":\"21\
"}","{\"outputMethod\":\"userDatabase\",\"username\":\"\",\"password\":\"\",\"se
rver\":\"\",\"port\":\"\",\"vendor\":\"Select a database
vendor\"}","{\"outputMethod\":\"dacaaDatabase\",\"vendor\":\"Select a database
vendor\"}"]
results in a array of Strings. The strings however loose their quotes and can
not be parsed further:
{root=[{\outputMethod\:\email\,\emailAddress\:\test@test.com\},
{\outputMethod\:\ftp\,\username\:\\,\password\:\\,\server\:\\,\port\:\21\},
{\outputMethod\:\userDatabase\,\username\:\\,\password\:\\,\server\:\\,\port\:\\
,\vendor\:\Select a database vendor\},
{\outputMethod\:\dacaaDatabase\,\vendor\:\Select a database vendor\}]}
Java code snippet:
public void testFunction(String reportsOutput) {
parser=factory.newJsonParser();
Map jsonData=parser.parseJson(reportsOutput);
System.out.println("reportsOutput: "+jsonData);
ArrayList rootJson;
String reportId=null;
try {
rootJson=(ArrayList)jsonData.get("root");
System.out.println("rootJson: "+rootJson);
for(int i=0;i<rootJson.size();i++) {
String tempString=(String)rootJson.get(i);
System.out.println("tempString: "+tempString);
jsonData=parser.parseJson(tempString); // Exception: Invalid JSON
System.out.println("jsonData: "+jsonData);
processSendReportFunction(jsonData,filename);
}
} catch(Exception exp) {System.out.println("ReportFunctions.sendReport:
Exception occurred: "+exp); }
}
Expected intermediate String:
{"outputMethod":"email","emailAddress":"test@test.com"}
So essentially the removing/replacing of the quotes fails.
Result is that quick-json can not be used on more complex objects generated
with javascript json functionality.
Original issue reported on code.google.com by norb...@vnitconsultancy.nl on 4 Apr 2015 at 11:41
Original issue reported on code.google.com by
norb...@vnitconsultancy.nl
on 4 Apr 2015 at 11:41