0
handlig初始化静态列表如果我这样做:GSON不正确
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"}]
这是为什么?