I have a sample record in oracle DB inside PersonalInformation table having column info[varchar] storing string values in JSON format. i.e :
Row 1. {"country":"germany"}
Row 2. {"language":"german"}
Now I want to get the response from a GET API as follows:
response :
{
"x1" : "value1",
**`"mapMetadata" :{"country":"germany","language":"german"}`** ,
"x3" : "value3"
}
So basically in code I want to covert JsonObject (org.google.GSON.JsonObject) to Map<String, Object> with key as mapMetadata.
I have tried this but not sure how to map it with my key "mapMetadata" and return the response as shown above.
JsonObject jsonObject = JsonParser.parseString(info).getAsJsonObject(); // info is of type String
HashMap<String, Object> yourHashMap = new Gson().fromJson(jsonObject, HashMap.class);
Reference: Convert JSONObject to Map