Map转Json
/*
Map item中索引为下划线命名方式,转为驼峰命名
*/
public JSON toCamelCaseFromMap(Object item) {
Map<String,Object> camelMapConfig = new HashMap<>();
for (String str : ((Map<String, Object>) item).keySet()) {
camelMapConfig.put(toCamelCase(str), ((Map<String, Object>) item).get(str));
}
String jsonStr = JSON.toJSONString(camelMapConfig);
JSONObject jsonObject = JSON.parseObject(jsonStr);
// if(Integer.parseInt(json.get("code").toString()) == 200 ){
return jsonObject;
// }
}
QuestionnareInfo q = com.alibaba.fastjson.JSONObject.toJavaObject(toCamelCaseFromMap(map.get("_source")), QuestionnareInfo.class);