I have a JSONObject
structured like this:
"data": {
"title": "Pool Party",
"date": {
"start": "2018-08-14T15:44:44.625Z",
"end": "2018-08-14T18:44:44.625Z"
}
and I'd like to convert it to
HashMap<String, String>
is there a way to structure the map in the same way for what regards the "start" and "end" field, which are under the "date" field?
I tried to convert it using Gson
like this:
Type type = new TypeToken<Map<String, String>>(){}.getType();
HashMap<String, String> params = Gson().fromJson(jsonString, type);
but I got this error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT
probably because of the structure of my JSON
string
Is there a way to get something like this? Thank you for your help.