The Class that I'm using with toJson
class LoadUserDTO: Serializable {
@SerializedName("userGuid")
var userGuid: String? = null
@SerializedName("userToken")
var userToken: String? = null
constructor(userGuid: String, userToken: String) {
this.userGuid = userGuid
this.userToken = userToken
}
}
And the rest of the use:
val payload = LoadUserDTO(userGuid = user.guid!!, userToken = user.token!!)
val jsonPayload = Gson().toJson(payload)
this.socketService.socket.emit(EndpointsEnum.AppLoadUser, jsonPayload)
The jsonPayload should be a JSON Object. Instead, the entire thing is a String of what should be a JSON Object:
"{"userGuid":"...","userToken":"..."}"
When this is received by the server, it's not receiving a JSON Object as the Web UI or Swift App sends, but is instead just a String, not converted to a JSON Object.