Details
-
Improvement
-
Status: Resolved
-
Medium
-
Resolution: Done
-
None
-
None
-
None
-
None
Description
Messagelib currently support only scalar method argument types.
It is possible to add support for them.
Consider this POJO
public class SomePojo { private int field1; private String field2; // + getters/setters }
And this RPC method
public interface SomeRpc { Result callMe(SomePojo input); }
This RPC method can be invoked like this:
{"jsonrpc":"2.0","id":2,"method":"callMe","params":{"field1":10,"field2":"ABC"}}
Also it is possible to exploit GSON feature to add explicit mapping of parameter name to java field name. Let's say you have parameters named "field-1" and "field-2"
{"jsonrpc":"2.0","id":2,"method":"callMe","params":{"field-1":10,"field-2":"ABC"}}
Now you can specify json field name using annotation `SerializedName`:
import com.google.gson.annotations.SerializedName; public class SomePojo { @SerializedName("field-1") private int field1; @SerializedName("field-2") private String field2; // + getters/setters }