Gson 解析数组如果是空能不能显示 []



 Gson gson = new GsonBuilder().serializeNulls().excludeFieldsWithoutExposeAnnotation().create();
String[] ceshi = {};
String jsonceshi = gson.toJson(ceshi);
System.out.println(jsonceshi);

显示的是null,能不能打印出 []

java gson

EX-蕾米朵露 10 years, 4 months ago

Your Answer