Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

using tExtractJsonFields to extract JSON response from tRestClient

Hi,
I am trying to tExtractJsonFields to parse the JSON response. But JSON response has dynamic keys.  How to parse this kind of JSON using tExtractJSONfields. I am using community edition of data integrator 5.5.
Following is an example
{
  "apple:ios": {
    "2015-10-20": {
      "downloads": 72,
      "updates": 27,
      "returns": 0,
      "net_downloads": 72,
      "promos": 0,
      "revenue": "0.00",
      "edu_downloads": 0,
      "gifts": 0,
      "gift_redemptions": 0,
      "storefront": "apple:ios",
      "store": "apple",
      "date": "2015-10-20"
    }
  },
  "google_play": {
    "2015-10-20": {
      "downloads": 68,
      "updates": 14,
      "returns": 0,
      "net_downloads": 68,
      "promos": 0,
      "revenue": "0.00",
      "edu_downloads": 0,
      "gifts": 0,
      "gift_redemptions": 0,
      "storefront": "google_play",
      "store": "google_play",
      "date": "2015-10-20"
    }
  }
}
Labels (3)
1 Reply
Anonymous
Not applicable
Author

Hi 
Check the response string to see which key it contains, and use the corresponding tExtractJsonFields to parse the string. Eg:
.....tJavaRow--runIf1---tFixedFlowInput1--main--tExtractJsonFields1
                  --runIf2---tFixedFlowInput2--main---tExtractJsonFields2
                   ...
on tJavaRow:
if(input_row.response.contains(" apple:ios")){
globalMap.put("is apple:ios",true);
}else{
globalMap.put("is apple:ios",false);
}

if(input_row.response.contains(" google_play")){
globalMap.put("is google_play ",true);
}else{
globalMap.put("is google_play ",false);
}

...

set the condition of runif1 as:
(Boolean)globalMap.get("is apple:ios ")


tExtractJsonFields1: configure to extract the values from the json string whose key is  apple:ios.
This solution is only apply to the situation the number of keys is limited, and the key can be one of the values which is listed on tJavaRow.

Best regards
Shong