Fastjson的SerializerFeature序列化屬性 --來自oschina bfleeee博客
QuoteFieldNames———-輸出key時是否使用雙引號,默認為true
QuoteFieldNames———-輸出key時是否使用雙引號,默認為true
WriteMapNullValue——–是否輸出值為null的字段,默認為false
WriteNullNumberAsZero—-數值字段如果為null,輸出為0,而非null
WriteNullListAsEmpty—–List字段如果為null,輸出為[],而非null
WriteNullStringAsEmpty—字符類型字段如果為null,輸出為”“,而非null
WriteNullBooleanAsFalse–Boolean字段如果為null,輸出為false,而非null。
/* 根據名稱和類型查詢小班信息 */
@RequestMapping("/getSBInfo")
@ResponseBody
public Object getSBInfo(@RequestParam Map map) {
JSONObject jsonArray = null;
JSONObject jsonArray = null;
if (map != null) {
//縣、鄉、村名稱
String county = (String) map.get("county");
String town = (String) map.get("town");
String village = (String) map.get("village");
//類型是縣、鄉、村
//"1"查詢鄉鎮, "2"查詢村, “3”查詢全部
String type = (String) map.get("type");
if (county != null && town != null && village != null) {
if (county != null && town != null && village != null) {
//查全部
Map mapAll = stateCountyService.getAll(county, town, village);
String str = JSON.toJSONString(mapAll,SerializerFeature.WriteMapNullValue);
jsonArray = JSONObject.parseObject(str);
} else if (county != null && town != null) {
} else if (county != null && town != null) {
//查村
Map mapVillage = stateCountyService.getVillge(county, town);
String str = JSON.toJSONString(mapVillage,SerializerFeature.WriteMapNullValue);
jsonArray = JSONObject.parseObject(str);
} else if (county != null) {
} else if (county != null) {
//查鄉鎮
Map mapTown = stateCountyService.getTown(county);
String str = JSON.toJSONString(mapTown,SerializerFeature.WriteMapNullValue);
jsonArray = JSONObject.parseObject(str);
}
}
}
return jsonArray;
}
