I am trying to call three functions. All of them return a json Array. Then I parse every array iterate over every object in the array and write it to a new json Array.
At the end i get an array with json objects from the three functions i am calling in the beginning.
The problem is that i want to call function 1 , 2 and 3 to be called asynchronously.
public JSONArray getdeals() throws Exception {
JSONArray amz = newJSONArray(a.function1());
JSONArray bb = new JSONArray(a.function2());
JSONArray ts = new JSONArray(a.function3());
JSONArray finalArray = new JSONArray();
for(int i=0; i<amz.length(); i++) {
finalArray.put(amz.getJSONObject(i));
}
for(int j=0; j<bb.length(); j++) {
finalArray.put(bb.getJSONObject(j));
}
for(int k=0; k<ts.length(); k++) {
finalArray.put(ts.getJSONObject(k));
}
return finalArray;
}
I am using Java 8. The final function is called through a endpoint using Spring Boot