Below is my method which makes the JSONObject
and then print out the JSONString
.
I am using Google GSON.
private String gen
If you are using Android Platform 23 then you shall able to use org.json.JSONObject instead:
private String generateData(ConcurrentMap>> dataTable, int i) {
JSONObject jsonObject = new JSONObject();
try {
JSONArray apArray = new JSONArray();
for (Integer i : ap) {
apArray.put(i.intValue());
}
JSONArray bpArray = new JSONArray();
for (Integer i : bp) {
bpArray.put(i.intValue());
}
jsonObject.put("description", "test data");
jsonObject.put("ap", apArray);
jsonObject.put("bp", bpArray);
Log.d("Json string", jsonObject.toString());
}catch(JSONException e){
Log.e("JSONException",e.getMessage());
}
System.out.println(jsonObject.toString());
return jsonObject.toString();
}