I need to post a request to a server containing the following JSON. I want to use DataContractJsonSerializer and DataContract, DataMember attributes on the classes representing a request such as
{"method":"mymethod","parameters":[10,"somestring"]}
This represents an RPC call
mymethod(10,"somestring").
in some API. There are many calls with different parameter lists in the API.
This is straightforward if the parameter list contains objects of type T where I can use generic List<T>
, but the API needs a list of parameters of different types (including non-primitive objects).
So how can I construct the DataContract for the parameters array ?
Thanks Lucas. So slightly restating the question to include complex types:-
{"method":"mymethod","parameters":[10,"somestring",{SomeProperty:value}]}
This represents a call to JSON RPC call mymethod(int,string,ComplexProperty)