I have want to create a jsonObject in java of this type:
"a": "b",
"c": {
"d": {
"e": [
"f",
"g",
"h"
]
}
}
Following is a snippet of the code where I try to add the value of "e" given in the form of the list:
import com.google.gson.JsonObject;
import java.util.ArrayList;
List<String> arr = new ArrayList<String>();
arr.add("f");
arr.add("g");
arr.add("h");
JsonObject arrayList = new JsonObject();
arrayList.add("e", arr);
In this portion I am getting an error:
java.util.List<java.lang.String> cannot be converted to com.google.gson.JsonElement
Any suggestion to resolve this issue will be appreciated. Thanks!
Try the following