Back

android - 使用Gson 和 Json 解析 json

发布时间: 2017-11-04 00:02:00

下面两个例子,都是解析最简单的 "一级"key:

gson:

                                Gson gson = new Gson();
                                JsonObject jsonObject = gson.fromJson(result, JsonObject.class);
                                name.setText(jsonObject.get("name").getAsString());

JSON方式:

                            JSONObject json = new JSONObject(response_result);
                            if(json.getInt("status") == 200){

Back