I have json array I want to show just value in a a dailog. Ho can I achieve this? This is the code i wrote
public JsonArray arrayListToJson(List<String> selectedItems) {
JsonObject jsonObject ;
JsonArray jsonArray = new JsonArray();
for (String selectedItem : selectedItems) {
jsonObject= new JsonObject();
jsonObject.addProperty(selectedItem, selectedItem);
jsonArray.add(jsonObject);
}
return jsonArray;
}
public ArrayList<String> getJsonValues(JsonArray jsonArray){
ArrayList<String> selectedValues= new ArrayList<String>();
Iterator<JsonElement> iterator =jsonArray.iterator();
while(iterator.hasNext()){
selectedValues.add(iterator.next().toString());
}
return selectedValues;
}