forked from kevin.shehu/GGD
FINALIZED : FULLY WORKING
TODO : DATA MANIPULATION
This commit is contained in:
@@ -12,9 +12,6 @@ import java.util.ArrayList;
|
||||
///url/sensors/id/read
|
||||
|
||||
public class ReadSensors4Partner {
|
||||
|
||||
|
||||
|
||||
public String FetchSensor4Box(String companyName, String token) throws Exception {
|
||||
|
||||
switch (companyName) {
|
||||
@@ -40,19 +37,22 @@ public class ReadSensors4Partner {
|
||||
|
||||
BoxCall4Partner boxCall4Partner = new BoxCall4Partner();
|
||||
String outputBox = boxCall4Partner.FetchBox(cName,token);
|
||||
String outputBoxFixed=outputBox.replace("[[","[") + outputBox.replace("]]","]"); //to make the
|
||||
String outputBoxFixed=outputBox.replace("[[","[") + outputBox.replace("]]","]");// To convert in Jsonarray we need to remove the array list brackets
|
||||
JSONArray jsonArray = new JSONArray(outputBoxFixed);
|
||||
|
||||
System.out.println("The working array:"+jsonArray);
|
||||
ArrayList<String> list=new ArrayList<String>();
|
||||
int loopTerminator = 0;
|
||||
|
||||
char par = '"';
|
||||
for(int j=0; j<jsonArray.length(); j++){
|
||||
JSONObject jsonobject = jsonArray.getJSONObject(j);
|
||||
String jsonID = jsonobject.getString("id");
|
||||
String jsonTag = jsonobject.getString("tag");
|
||||
|
||||
String sensorOutput = httpCall.HttpGet(baseURL + "sensors/" + jsonID + "/read" + "?access_token=" + token, token);
|
||||
list.add(sensorOutput);
|
||||
String sensorTag= par+"sensortag"+par+":"+jsonTag+"}]";
|
||||
String makingList=sensorOutput.replace("}]","") ;
|
||||
list.add(makingList+","+sensorTag); // This modification of the list is done for the purpse of converting this list to a jsonarray.
|
||||
|
||||
writingIntoFile.WriteFile(homeRoot + jsonID + ".json", sensorOutput + jsonTag);
|
||||
loopTerminator++;
|
||||
if(loopTerminator == jsonArray.length()){
|
||||
|
||||
Reference in New Issue
Block a user