String response="{\"name\":\"tom\",\"sex\":\"male\"}"
JsonElement parse = new JsonParser().parse(response.getData());
// 判断是否是json对象
System.out.println(parse.isJsonObject());
// 根据字段名,取值
System.out.println(parse.getAsJsonObject().get("name"));
String response="{\"name\":\"tom\",\"sex\":\"male\"}"
JsonElement parse = new JsonParser().parse(response.getData());
// 判断是否是json对象
System.out.println(parse.isJsonObject());
// 根据字段名,取值
System.out.println(parse.getAsJsonObject().get("name"));
本文标题:从json中获取属性
本文链接:https://www.haomeiwen.com/subject/ficbgqtx.html
网友评论