ServiceStack returning JSV instead of JSON -


i have service created servicestack. updated servicestack libraries , getting jsv responses instead of json responses.

the request looks like:

post http://localhost/api/rest/poll/create?format=json&pollformat=1 http/1.1 host: localhost connection: keep-alive content-length: 160 accept: */* origin: http://localhost x-requested-with: xmlhttprequest user-agent: mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/28.0.1500.95 safari/537.36 content-type: application/x-www-form-urlencoded; charset=utf-8 dnt: 1 referer: http://localhost accept-encoding: gzip,deflate,sdch accept-language: en-us,en;q=0.8 cookie:   question=this+is+a+test&answers=yes%2cno& 

and response looks like:

http/1.1 200 ok cache-control: private content-type: application/json; charset=utf-8 server: microsoft-iis/7.5 x-powered-by: servicestack/3.956 win32nt/.net x-aspnet-version: 4.0.30319 x-powered-by: asp.net date: mon, 12 aug 2013 21:20:33 gmt content-length: 437  {id:1,question:this test,answers:[{id:1,text:yes,votes:0},{id:2,text:no,votes:0}],isopen:1,totalvotes:0}} 

note i've trimmed down jsv in response bit make easier read, , such, content-length incorrect example.

from understand, default contenttype servicestack should json

so why getting jsv contenttype of application/json?

edit:

here request dto looks like:

[route("/poll/create", verbs = "post")] public class pollrequest : ireturn<object> {     public string question { get; set; }     public string answers { get; set; }     public int? pollformat { get; set; } } 

here service looks like:

public class pollservice : service {     public object post(pollrequest request)     {         //         // work required create new poll         //         poll p = new poll();         if(request.pollformat.hasvalue)         {             return jsonserializer.deserializefromstring<object>(p.json);         }         else         {             return postconvertor.convertto(p);         }     } } 

here poll response looks like:

public class poll {     public int id { get; set; }     public string question { get; set; }     public collection<answer> answers { get; set; }     public int isopen { get; set; }     public int totalvotes { get; set; }      public class answer     {         public int id { get; set; }         public string text { get; set; }         public int votes { get; set; }     } } 

turns out had parameter being sent service defined how response returned. if parameter set generate json string manually (represented p.json property in editied question), , return deserialized object string so:

return jsonserializer.deserializefromstring<object>(p.json) 

in previous versions of servicestack appears deserialized object result in string contents being same input json (not sure why since seems waste of cpu). newer versions of servicestack appear deserialize json string well, string uses jsv formatting.

i think reason doing (though i'm not sure) trying generic object json when return it converted json or xml depending on requester wanted. current implementation returns json formatted string, if replace the

return jsonserializer.deserializefromstring<object>(p.json) 

with

return p.json 

then think keeping response same is.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -