gosn解析jsonlist

    public static  ArrayList jsonToArrayList(String json, Class clazz)

    {
        Type type = new TypeToken>(){}.getType();
        ArrayList jsonObjects = new Gson().fromJson(json, type);
        ArrayList arrayList = new ArrayList();
        for (JsonObject jsonObject : jsonObjects)
        {
            arrayList.add(new Gson().fromJson(jsonObject, clazz));
        }
        return arrayList;
    }

你可能感兴趣的:(gosn解析jsonlist)