public class test { public static void main(String []args){ String postResult ="{"code":200,"message":"success","data":[{"name":"n1","result":"1"}]}"; Gson gson = new Gson(); JsonObject jsonObject = gson.fromJson(postResult,JsonObject.class); JsonArray jsonDataArray = jsonObject.getAsJsonArray("data"); for (int i = 0, size = jsonDataArray.size(); i < size; i++) { JsonObject jsonObject1 = jsonDataArray.get(i).getAsJsonObject(); System.out.println("name: "+jsonObject1.get("name").getAsString()); System.out.println("result: "+jsonObject1.get("result").getAsInt()); } }
————————————————
版权声明:本文为CSDN博主「WangPing1223」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/WangPing1223/java/article/details/76199118