I'm using the Koltin language with GSON library to create/parse JSON. I have the following string that represents a JSON object
val jsonString = "{ \"age\": 22, \"height\" : 1.8, \"profession\":\"Student\", \"at_room\": false, \"gender\": \"male\",\"pictures\": []}"
When I try to convert this string to a JSON Object, by doing
val jsonData = JsonParser().parse(jsonString).asJsonObject
I get the following error:
[] can not be converted to JSON
I guess that this error is due to the fact that pictures
is a JSONArray and not a primitive type. Anyway, I would like to know how to convert this string to a JSON Object correctly.