erizet / SignalA

A SignalR client for Android.
Apache License 2.0
193 stars 90 forks source link

Cannot convert to JSONObject #51

Open akovacevic opened 10 years ago

akovacevic commented 10 years ago

When receiving a message from SignalR, i get the following error:

686-686/com.example.adis.shuttleservice E/TransportHelper﹕ Error when calling setMessage on connection. org.json.JSONException: Value hello at 0 of type java.lang.String cannot be converted to JSONObject

erizet commented 10 years ago

Place a breakpoint here https://github.com/erizet/SignalA/blob/master/SignalA/src/main/java/com/zsoft/signala/Transport/TransportHelper.java#L64

And look at the respone and messageArray variables...then paste them here.

akovacevic commented 10 years ago

It works just fine when you send across an object. But fails to do the same when you send over a JSON wrapped int or String.

I pulled the code down as a dependency and don't have access the the .java files at the moment. When i get more free time i'll go back and see If i can get to the root of the problem.

erizet commented 10 years ago

Ok, in the meantime can you post your code here?

gxshao commented 7 years ago

did you guys solved it ? i am stuck right here,looking for some help..thanks.

gxshao commented 7 years ago

Oh..i checked the source code,and i found that JSONArray (var: messagesArray=response.optJSONArray ()) doesn't work properly....the messagesArray have no JSONObject but String.....

this is before: before

after i changed value of messageArray: after

am i right?

gxshao commented 7 years ago

i was solved this problem yesterday..and i committed it to my own repo.Add a for loop after L64,Tansform the String to JSONObject before calling it.