Uploaded image for project: 'jsonrpc'
  1. jsonrpc
  2. JSONRPC-18

Add support for invocation of RPC method with object argument

    XMLWordPrintable

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
      }
       
      

       

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            rkosegi Richard Kosegi
            rkosegi Richard Kosegi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: