ServiceStack retornando o JSV em vez do JSON
Eu tenho um serviço criado com ServiceStack. Recentemente, atualizei as bibliotecas do ServiceStack e agora estou obtendo respostas do JSV em vez de respostas do JSON.
O pedido parece algo como:
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&
E a resposta parece algo como:
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}}
Observe que reduzi o JSV na resposta um pouco para facilitar a leitura e, como tal, o Content-Length estará incorreto para o exemplo.
Pelo que entendi, o ContentType padrão para ServiceStack deve serJSON
Então, por que estou recebendo o JSV de volta com um ContentType de application / json?
EDITAR:
Aqui está o que o meu pedido parece:
[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; }
}
Aqui está o meu serviço:
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<object>(p.JSON);
}
else
{
return PostConvertor.ConvertTo(p);
}
}
}
Aqui está a resposta da minha pesquisa:
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; }
}
}