我正在尝试使用 json.org 的 JSONArray 对象构造函数将 Java bean 列表转换为 JSON 字符串。
这是豆:
package jackiesdogs.bean;
import java.util.*;
public class UploadLog {
private String logDescription;
private List<String> headings;
private List<List<String>> log;
public UploadLog(String logDescription, List<String> headings, List<List<String>> log) {
this.logDescription = logDescription;
this.headings = headings;
this.log = log;
}
public String getLogDescription() {
return logDescription;
}
public void setLogDescription(String logDescription) {
this.logDescription = logDescription;
}
public List<String> getHeadings() {
return headings;
}
public void setHeadings(List<String> headings) {
this.headings = headings;
}
public List<List<String>> getLog() {
return log;
}
public void setLog(List<List<String>> log) {
this.log = log;
}
}
这是我用来将其转换为 JSON 的代码:
JSONArray outputJSON = new JSONArray(output,false);
我希望得到以下信息:
[{"headings":[{"Vendor Order Id"}],"logDescription":"You are attempting to upload a duplicate order.","log":[{[{"132709B"}]}]}]
但相反,我得到:
[{"headings":[{"bytes":[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}],"empty":false}],"logDescription":"You are attempting to upload a duplicate order.","log":[{}]}]
有任何想法吗?