khaintt / android-json-rpc

Automatically exported from code.google.com/p/android-json-rpc
0 stars 0 forks source link

Issue when adding array as params, corrupts rest of the params #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create array of two strings
2. Add array as param
3. Add a second string as param
4. Observe in debug mode that 2nd param is corrupted

What is the expected output? What do you see instead?

The 2nd param looks like a serialized pointer form? Not sure.. I get something 
like this on the php side: [Ljava.lang.String;@44f42cb8

What version of the product are you using? On what operating system?

0.3.4 on Mac

Please provide any additional information below.

In file JSONRPCClient, in method protected JSONObject doRequest(String method, 
Object[] params) throws JSONRPCException

You need to change:

            if(params[i].getClass().isArray()){
                jsonParams.put(getJSONArray((Object[])params[i]));
            }

            jsonParams.put(params[i]);

to

            if(params[i].getClass().isArray()){
                jsonParams.put(getJSONArray((Object[])params[i]));
            }
            else {
                jsonParams.put(params[i]);
            }

Then everything works as expected. 

Original issue reported on code.google.com by r...@ordbogen.com on 10 Aug 2012 at 9:15

GoogleCodeExporter commented 9 years ago
Same problem here, fix works!
Godsend.

Original comment by timvangi...@gmail.com on 4 Sep 2012 at 5:45