1
I’m having trouble returning json to my mvc 5 api.
In the Get method it returns a string in this format:
public string Get()
{
return "{\"data\":[{\"Codigo\":\"AAAA\",\"Finalidade\":\"AAAA\"},{\"Codigo\":\"AAAA\",\"Finalidade\":\"AAAA\"}]}"
}
When I ask on my page localhost:9640/api/apiimovel?formato=json
look at the format:
"{\"data\":[{\"Codigo\":\"AAAA\",\"Finalidade\":\"AAAA\"},{\"Codigo\":\"AAAA\",\"Finalidade\":\"AAAA\"}]}"
But when I do this query by the normal controller json returns correct !!
What happens to this problem ?
You mean when you access
localhost:9640/api/apiimovel?formato=json
, the bars come in the string? In C# you send"aa\"bb"
, and on the other side, instead of receivingaa"bb
, you’re gettingaa\"bb
?– carlosrafaelgn
I believe that you do not understand very well the concept of web.api. Please read this link and it may help you a lot: http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api
– Reiksiel