socket.io-client-java icon indicating copy to clipboard operation
socket.io-client-java copied to clipboard

Unable to emit JSON object instead it is emitting Stringified Json in Client Version - 1.0.2

Open mdhanif-simformsolutions opened this issue 1 year ago • 1 comments

Describe the bug I am trying to send a json object to my server something like this :-

val jsonObject = JsonObject()
jsonObject.addProperty("domain", "test")
jsonObject.addProperty("type", "test")
jsonObject.addProperty("bearer", "test")
mSocket?.emit("subscribe", jsonObject)

But when I see the logs what it sends is :- ["subscribe","{\"domain\":\"test\",\"type\":\"test\",\"bearer\":\"test\"}"]

Instead It should be :- ["subscribe",{"domain":"test","type":"test","bearer":"test"]

Not sure why is it being strigified here ?

To Reproduce

  • Used mSocket?.connect() to establish a proper socket connection which works good
  • Used mSocket?.emit() to emit the data with json object which is being stringified

Socket.IO server version: 2.2.0

Socket.IO java client version: 1.0.2

Expected behavior Json Object should be send as it is instead of being converted to string

Additional context In iOS it works good but seems something is missing in android

Hi! Which JsonObject are you using? The one from org.json?

darrachequesne avatar Mar 14 '24 16:03 darrachequesne

Closed due to inactivity, please reopen if needed.

darrachequesne avatar Jul 10 '24 09:07 darrachequesne