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"}]
這是爲什麼?