简体   繁体   中英

How i can get the parse the json response such that i can get only keys with Java?

How can I parse the JSON response such that I can get only randomly generated keys from JSON like this

  "6e38fad50-39a0-11e9-9511-0242ac110002"

available in JSON?

Response:

{
    "results": {
        "6e38fd50-39a0-11e9-9511-0242ac110002": {
            "name": "11TAG_WITH_CAPS1",
            "type": "CAMPAIGN"
        },
        "744d29d0-39a2-11e9-8e34-0242ac110004": {
            "name": "121TAG_WITH_CAPS1",
            "type": "CAMPAIGN"
        }
    }

Without using java script

Using GSON and JSON.

Your question is not so clear
But see this sample how to convert the json and iterate in it.

 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!'); } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM