Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
"data" :
"data" :
After tRest, you can use a tExtractJsonField to extract the value from the response string, if the response format is not fixed, parse the response on a tJavaRow first, and then use different tExtractJsonField with different mapping base on the parse result to extract the value...
public static Integer getJSONValue(Object str) {
Integer myNullInt = null;
if(str == null || str.toString().trim().length()==0) {
return myNullInt;
}
String object = str.toString().trim();
int id;
try {
id = Integer.parseInt(object);
return id;
} catch(Exception e) {
String[] jsonArr = object.split(",");
for(int i=0;i<jsonArr.length; i++) {
if(jsonArr.contains("\"value\"")) {
String[] idVal = jsonArr.split(":");
idVal = idVal.replace('"', ' ').replace('}', ' ').replace('{', ' ').trim();
try {
id = Integer.parseInt(idVal);
return id;
} catch (Exception ex) {
return myNullInt;
}
}
}
return myNullInt;
}
}
I have yet been able to get the tRest component to return anything other than a string which I can't figure out how to process.
After tRest, you can use a tExtractJsonField to extract the value from the response string, if the response format is not fixed, parse the response on a tJavaRow first, and then use different tExtractJsonField with different mapping base on the parse result to extract the value...
public static Integer getJSONValue(Object str) {
Integer myNullInt = null;
if(str == null || str.toString().trim().length()==0) {
return myNullInt;
}
String object = str.toString().trim();
int id;
try {
id = Integer.parseInt(object);
return id;
} catch(Exception e) {
String[] jsonArr = object.split(",");
for(int i=0;i<jsonArr.length; i++) {
if(jsonArr.contains("\"value\"")) {
String[] idVal = jsonArr.split(":");
idVal = idVal.replace('"', ' ').replace('}', ' ').replace('{', ' ').trim();
try {
id = Integer.parseInt(idVal);
return id;
} catch (Exception ex) {
return myNullInt;
}
}
}
return myNullInt;
}
}