简体   繁体   中英

ServiceStack deserializing Get request when not scalar

Say I have an Order object, with a unique OrderNo (effectively an id). It looks like this:

[Route("/orders/{OrderNo}", "GET")]
class Order
{
    OrderNo OrderNo;
}

class OrderNo
{ 
  ulong Value {get;set;}
}

Now with a regular GET request like so:

www.myservice.com/orders/123

I get a deserialization error because OrderNo property of Order is not scalar. I'm wondering how I would be able to customize the deserialization to accomodate for the extra layer.

Should be pretty obvious what the problem is, you can't match on Object graphs in the Route mappings. Make OrderNo a scalar variable (eg int, long, etc).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM