问题
Can I set my request object by http parameters with GET method, if request contains not primitive object. I can do it for POST method with json, but does exist some GET alternative?
[DataContract]
[RestService("/foo")]
public class FooRequest
{
[DataMember]
public string Color1 { get; set; }
[DataMember]
public FooDto Dto { get; set; }
}
public class FooDto
{
public string Color2 { get; set;}
}
In this example Color1 is set but how can I set Dto.color2?
http://server/fooservice/servicestack/foo?Color1=blue&Dto.Color2=red
回答1:
In ServiceStack, you can set complex type properties on a QueryString by using the JSV Format. See this earlier answer for an example.
So to set the Complex Type Dto property your queryString would look like:
http://server/fooservice/servicestack/foo?Color1=blue&Dto={Color2:red}
来源:https://stackoverflow.com/questions/13360098/http-get-method-parameter-format-for-object