shourav9884 / android-json-rpc Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/android-json-rpc
Automatically exported from code.google.com/p/android-json-rpc
What steps will reproduce the problem?
1. new a JSONObject and put a string field
JSONObject jsonObject = new JSONObject();
jsonObject.put("string": "中文");
2. New a json rpc client:
JSONRPCClient client = ...
3. Use the jsonObject as json-rpc parameter:
client.callJSONObject("method": jsonObject);
What is the expected output? What do you see instead?
The remote side receives '????' instead of "中文"
What version of the product are you using? On what operating system?
Working with Android-7 and android-jsonrpc-0.3.1
Please provide any additional information below.
Can be fixed by changing lines in org.alexd.jsonrpc.JSONEntity:
package org.alexd.jsonrpc;
import java.io.UnsupportedEncodingException;
import org.apache.http.Header;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;
/**
* Provides a HttpEntity for json content
*/
class JSONEntity extends StringEntity
{
public JSONEntity(JSONObject jsonObject) throws UnsupportedEncodingException
{
super(jsonObject.toString(), "utf-8");
setContentEncoding("utf-8");
}
@Override
public Header getContentType()
{
return new BasicHeader(HTTP.CONTENT_TYPE, "application/json");
}
}
Original issue reported on code.google.com by lvqier
on 26 Jun 2012 at 2:12
In the case of using the Wifi, android-json-rpc Timeout errors often occur, But
3G but not,please check.thanks!!!
Original issue reported on code.google.com by [email protected]
on 23 Aug 2012 at 2:47
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 [email protected]
on 10 Aug 2012 at 9:15
Please add authorization. Such as:
request.addHeader("Authorization", "Basic " +
Base64Coder.encodeString((username + ":" + password)));
Original issue reported on code.google.com by [email protected]
on 17 Oct 2012 at 12:52
I currently use the version 2.1 of lib and i Try change to 3.x but i get the
follow error:
09-04 20:03:23.537: E/AndroidRuntime(267): Caused by:
java.lang.NoClassDefFoundError: org.alexd.jsonrpc.JSONRPCParams$Versions
09-04 20:03:23.537: E/AndroidRuntime(267): at
br.com.icarros.network.JsonRpcRequest$ManagerAsyncTask.doInBackground(JsonRpcReq
uest.java:104)
09-04 20:03:23.537: E/AndroidRuntime(267): at
br.com.icarros.network.JsonRpcRequest$ManagerAsyncTask.doInBackground(JsonRpcReq
uest.java:1)
09-04 20:03:23.537: E/AndroidRuntime(267): at
android.os.AsyncTask$2.call(AsyncTask.java:185)
09-04 20:03:23.537: E/AndroidRuntime(267): at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-04 20:03:23.537: E/AndroidRuntime(267): ... 4 more
Original issue reported on code.google.com by [email protected]
on 4 Sep 2012 at 11:08
In JSONRPCClient / JSONRPCThreadedClient both methods
protected JSONObject doRequest(String method, Object[] params)
protected static JSONArray getJSONArray(Object[] array)
use [ params[i] | item ].getClass().isArray() that leads to a null pointer
xception when params[i] or item is null.
Original issue reported on code.google.com by [email protected]
on 8 Oct 2014 at 4:08
What steps will reproduce the problem?
1. Call any method with JSON-RPC version 2 specified in request on a version 2
Server.
For example:
JSONRPCClient client =
JSONRPCClient.create("http://localhost:3000",JSONRPCParams.Versions.VERSION_2);
client.setConnectionTimeout(2000);
client.setSoTimeout(2000);
try
{
int result = client.callInt("add",5,6);
} catch (JSONRPCException e) {
e.printStackTrace();
}
What is the expected output? What do you see instead?
expected request:
{"id":1445201434,"jsonrpc":"2.0","method":"add","params":[5,6]}
expected result: {"jsonrpc":"2.0","id":1445201434,"result":11}
actual request: {"id":-400656856,"method":"add","params":[5,6]}
actual result: org.alexd.jsonrpc.JSONRPCException: {"message":"Invalid
request","code":-32600}
What version of the product are you using? On what operating system?
svn version 58 (http://android-json-rpc.googlecode.com/svn/trunk)
Please provide any additional information below.
The following changes are fixing the "Invalid Request" response.
Index: android-json-rpc/src/org/alexd/jsonrpc/JSONRPCClient.java
===================================================================
--- android-json-rpc/src/org/alexd/jsonrpc/JSONRPCClient.java (revision 58)
+++ android-json-rpc/src/org/alexd/jsonrpc/JSONRPCClient.java (working copy)
@@ -86,6 +86,9 @@
jsonRequest.put("id", UUID.randomUUID().hashCode());
jsonRequest.put("method", method);
jsonRequest.put("params", jsonParams);
+ if(version==Versions.VERSION_2) {
+ jsonRequest.put("jsonrpc", "2.0");
+ }
}
catch (JSONException e1)
{
@@ -101,7 +104,9 @@
jsonRequest.put("id", UUID.randomUUID().hashCode());
jsonRequest.put("method", method);
jsonRequest.put("params", params);
- jsonRequest.put("jsonrpc", "2.0");
+ if(version==Versions.VERSION_2) {
+ jsonRequest.put("jsonrpc", "2.0");
+ }
} catch (JSONException e1) {
throw new JSONRPCException("Invalid JSON request", e1);
}
Original issue reported on code.google.com by [email protected]
on 1 Apr 2013 at 9:08
In the JSONRPCHttpClient class in the doJSONRequest function an error
occurs, if the JSONRPC Server returns a result (not a error).
In the JSONRPC 2.0 Specification the "error" parameter of the response
object is omitted at succes.
Because 'jsonObject.get("error")' returns "JSONObject["error"] not found."
an exception gets thrown.
I replaced this code:
// Check for remote errors
Object jsonError = jsonResponse.get("error");
if (!jsonError.equals(null)) {
throw new JSONRPCException(jsonError);
} else {
return jsonResponse;
}
with the following:
// Check for remote errors
if (jsonResponse.has("error")) {
throw new JSONRPCException(jsonResponse.get("error"));
} else {
return jsonResponse;
}
Original issue reported on code.google.com by [email protected]
on 4 Feb 2010 at 12:41
What steps will reproduce the problem?
1. Call remote function with signature foo(int[] blah);
What is the expected output?:
Server should receive [1,2,55] as the param.
What do you see instead?:
Server receives "["\id98459875" which is a result of toString() on array.
What version of the product are you using?:
latest
FIX:
protected JSONObject doRequest(String method, Object[] params)
throws JSONRPCException, IOException {
// Copy method arguments in a json array
JSONArray jsonParams = new JSONArray();
for (int i = 0; i < params.length; i++) {
//[by gnugu]: if object is array
// we need to add JSONArray
if (params[i].getClass().isArray()) {
JSONArray param = new JSONArray();
Object arr = params[i];
int len = Array.getLength(arr);
for (int j = 0; j < len; j++) {
param.put(Array.get(arr, j));
}
jsonParams.put(param);
} else {
jsonParams.put(params[i]);
}
}
// Create the json request object
JSONObject jsonRequest = new JSONObject();
try {
// id hard-coded at 1 for now
jsonRequest.put("id", 1);
jsonRequest.put("method", method);
jsonRequest.put("params", jsonParams);
} catch (JSONException e1) {
throw new JSONRPCException("Invalid JSON request", e1);
}
return doJSONRequest(jsonRequest);
}
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 10:09
Would you mind uploading the library to maven central or some other public
maven repository?
Original issue reported on code.google.com by [email protected]
on 5 Aug 2013 at 8:41
What steps will reproduce the problem?
1. Make a callJSONObject to a WS which returns a error object like the following
{
"error": {
"code": -32001,
"message": "Callback Service RPC Error code",
"data": {}
},
"id": "1234",
"jsonrpc": "2.0"
}
What is the expected output? What do you see instead?
The expected output should be a JSONObject with the code, message and data
fields. What I see instead it´s a JSONRPCException because the result is null.
What version of the product are you using? On what operating system?
version 0.3.4
Please provide any additional information below.
The JSON-RPC Specification states that errors from -32000 to -32099 are
reserved for implementation-defined server-errors. They shouldn't raise a
Exception.
Original issue reported on code.google.com by [email protected]
on 17 Feb 2014 at 2:02
Attachments:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.