首页 > 解决方案 > 如何从 json 对象中获取数据

问题描述

如何从给定 JSON 数据的 JSON 数据中获取特定的数据对象:

{
    "customer":{
        "id":1117198024800,
        "email":"abc@gmail.com",
        "accepts_marketing":false
    }
}

我需要从上面的数据中解析ID,谁能帮帮我。提前致谢!!!

标签: androidjson

解决方案


If you will use it as string:

JSONObject reader = new JSONObject(data);
JSONObject customer = reader.getJSONObject("customer");
String id = (String) customer.getString("id");

推荐阅读