Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert to JSONObject #51

Open
akovacevic opened this issue Sep 22, 2014 · 6 comments
Open

Cannot convert to JSONObject #51

akovacevic opened this issue Sep 22, 2014 · 6 comments

Comments

@akovacevic
Copy link

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
Copy link
Owner

erizet commented Sep 22, 2014

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
Copy link
Author

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
Copy link
Owner

erizet commented Sep 24, 2014

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

@gxshao
Copy link

gxshao commented Sep 7, 2017

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

@gxshao
Copy link

gxshao commented Sep 7, 2017

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
Copy link

gxshao commented Sep 8, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants