ServiceStack, возвращающий JSV вместо JSON
У меня есть сервис, созданный с помощью ServiceStack. Недавно я обновил библиотеки ServiceStack, и теперь я получаю ответы JSV вместо ответов JSON.
Запрос выглядит примерно так:
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, like 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&
И ответ выглядит примерно так:
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 is a test,Answers:[{Id:1,Text:yes,Votes:0},{Id:2,Text:no,Votes:0}],IsOpen:1,TotalVotes:0}}
Обратите внимание, что ямы немного сократили JSV в ответе, чтобы его было легче читать, и, следовательно, Content-Length будет неверным для примера.
Насколько я понимаю, по умолчанию ContentType для ServiceStack должен бытьJSON
Так почему же я возвращаю JSV с ContentType приложения / json?
РЕДАКТИРОВАТЬ:
Вот как выглядит мой запрос dto:
[Route("/poll/create", Verbs = "POST")]
public class PollRequest : IReturn
{
public string Question { get; set; }
public string Answers { get; set; }
public int? PollFormat { get; set; }
}
Вот как выглядит мой сервис:
public class PollService : Service
{
public object Post(PollRequest request)
{
//
// do work required to create new poll
//
Poll p = new Poll();
if(request.PollFormat.HasValue)
{
return JsonSerializer.DeserializeFromString(p.JSON);
}
else
{
return PostConvertor.ConvertTo(p);
}
}
}
Вот как выглядит мой ответ на опрос:
public class Poll
{
public int Id { get; set; }
public string Question { get; set; }
public Collection 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; }
}
}