1,将Json字符串转化为Json
try {
try {
Gson gson = new Gson();
MessageModle msg = gson.fromJson(responceData, MessageModle.class);
} catch (JsonSyntaxException var4) {
throw new JsonFormatException(var4);
}
} catch (JsonFormatException e) {
e.printStackTrace();
}
2, 将hashMap转换为Json字符串
Map<String, Strig> param = new Hashmap<>();
Param.put(“userName”, “xiaoming”);
Gson gson = new Gson();
String request = gson.toJson(param);