I am trying to make my WCF service method to return JSON-object, but it doesn't work, when I open in a web browser it shows xml.
How can I make this method return JSON?
I have inserted [WebGet(ResponseFormat = WebMessageFormat.Json)], but that didn't help
[WebGet(ResponseFormat = WebMessageFormat.Json)]
protected override IEnumerable<KeyValuePair<string, SampleItem>> OnGetItems()
{
// TODO: Change the sample implementation here
if (items.Count == 0)
{
items.Add("A", new SampleItem() { Value = "A" });
items.Add("B", new SampleItem() { Value = "B" });
items.Add("C", new SampleItem() { Value = "C" });
}
return this.items;
}