Can Gson classes contain fields of type JSONObject? Here is my GSON class
class Item {
@Expose
var name: String? = ""
@Expose
var type: String? = ""
@Expose
@SerializedName("agr")
var aggregate: JSONObject? = null
@Expose
@SerializedName("seg")
var segments: JSONObject? = null
@Expose
@SerializedName("ts")
var timestamp: String? = ""
}
The JSONObject fields segments and aggregate remains an empty JSONObject when serialised (in Retrofit using default GsonConverterFactory). here's what I got. Any suggestions to get it write?
{"items":[{"agr":{},"name":"Logged In","seg":{},"ts":"2017-10-17T12:20:32Z","type":"event"}]}