0

As shown in answer on this question ServiceStack by default uses JSV format for complex objects when they are passed in QueryString.

Is it possible to set ServiceStack to use "default" JSON instead of JSV? Like instead of doing:

http://server.com/fooservice/servicestack/foo?Color1=blue&Dto={Color2:red}

I would prefer to pass:

http://server.com/fooservice/servicestack/foo?Color1=blue&Dto={"Color2":"red"}

Any way to do that?

Community
  • 1
  • 1
nikib3ro
  • 20,366
  • 24
  • 120
  • 181

1 Answers1

2

No, only (the more human-friendly) JSV format is supported for deserializing complex types on the QueryString. You can use JSON in HTTP POST's.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • So, if I need to access http://server/Persons instead of staying "true to REST" and doing that call with HTTP GET I would just switch to HTTP POST? That's the way you recommend? – nikib3ro Feb 04 '14 at 20:56
  • 1
    @kape123 if it's a query I recommend using a GET, but if you don't want to use JSV then you should strive to make the request flat and only contain primitive values, e.g ?Color2Name=xx&Color2Value=xx. – mythz Feb 05 '14 at 02:30
  • I would love to use JSV, but since I'm querying service from Android app (writing it in Eclipse, not Xamarin), there no support for JSV within the [Jackson JSON library I'm using](https://github.com/FasterXML/jackson). I guess I'll be forced to write either my own Serializer within Jackson or extend ServiceStack's support for parsing JSON within the QueryString. Is supporting JSON in QueryString something you plan or working / allowing others to work on? – nikib3ro Feb 05 '14 at 18:05
  • @kape123 Sending JSON on the querystring is not desirable - neither is supporting multiple strategies/formats for parsing complex type QueryStrings. I recommend avoid requiring complex types with a flat parameter list, or POST'ing JSON or just hand-crafting the JSV QueryString params when needed. – mythz Feb 05 '14 at 19:33