所以我有一个如下所示的 JSON 对象:
{
"accessToken" : "<dont need this>",
"clientToken" : "<nor this>",
"selectedProfile" : {
"id" : "<nope>",
"name" : "<I need this>",
"legacy" : true
},
"availableProfiles" :
[
{
"id" : "<not this>",
"name" : "<not this>",
"legacy" : true
}
]
}
所以我需要的是selectedProfile
> name
。我能够提取选定的配置文件
,我可以重复该过程吗?我应该怎么做才能取回它?
最佳答案
JsonReader reader = new JsonReader(yourString);
JsonObject base = reader.readObject();
JsonObject profile = base.getJsonObject("selectedProfile");
String name = profile.getJsonString("name");
然后 name 应该是你想要的对象。
关于java - 获取 JSON 项目内部的 JSON 项目 Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34453957/