[英]How i can get the parse the json response such that i can get only keys with Java?
如何解析 JSON 響應,以便我只能像這樣從 JSON 中獲取隨機生成的密鑰
"6e38fad50-39a0-11e9-9511-0242ac110002"
在 JSON 中可用?
回復:
{
"results": {
"6e38fd50-39a0-11e9-9511-0242ac110002": {
"name": "11TAG_WITH_CAPS1",
"type": "CAMPAIGN"
},
"744d29d0-39a2-11e9-8e34-0242ac110004": {
"name": "121TAG_WITH_CAPS1",
"type": "CAMPAIGN"
}
}
不使用java腳本
使用 GSON 和 JSON。
你的問題不是很清楚
但是請參閱此示例如何轉換 json 並在其中進行迭代。
var jsonStr = JSON.parse('{ "results": { "6e38fd50-39a0-11e9-9511-0242ac110002": { "name": "11TAG_WITH_CAPS1", "type": "CAMPAIGN" }, "744d29d0-39a2-11e9-8e34-0242ac110004": { "name": "121TAG_WITH_CAPS1", "type": "CAMPAIGN" } }}'); var results = jsonStr.results; for (result in results){ alert(result); if(result == '6e38fd50-39a0-11e9-9511-0242ac110002'){ alert('found it!'); } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.