【发布时间】:2012-04-24 09:03:25
【问题描述】:
如果我这样做:
public static volatile ArrayList<Process> processes = new ArrayList<Process>(){
{
add(new Process("News Workflow", "This is the workflow for the news segment", "image"));
}
};
然后是这个:
String jsonResponse = gson.toJson(processes);
jsonResponse 为空。
但如果我这样做:
public static volatile ArrayList<Process> processes = new ArrayList<Process>();
processes.add(new Process("nam", "description", "image"));
String jsonResponse = gson.toJson(processes);
Json 响应是:
[{"name":"nam","description":"description","image":"image"}]
这是为什么呢?
【问题讨论】: