-1

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.

molamk
  • 4,076
  • 1
  • 13
  • 22
  • 1
    Possible duplicate of [JSON parsing using Gson for Java](https://stackoverflow.com/questions/5490789/json-parsing-using-gson-for-java) – Forketyfork Feb 26 '19 at 20:08
  • Possible duplicate of [Java GSON: Getting the list of all keys under a JSONObject](https://stackoverflow.com/questions/31094305/java-gson-getting-the-list-of-all-keys-under-a-jsonobject) – Federico klez Culloca Feb 26 '19 at 20:08

1 Answers1

0

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!');
  }
}
JavaSheriff
  • 7,074
  • 20
  • 89
  • 159