Web service return string in JSON format



How to return string JSON format in webservice?


currently shown:



<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://example.net/ws1/">[
{
"name":"John"
},
{
"name":"Susan,
}


]


how to get rid: - - - at the end of the result..?



[WebMethod(Description = "Show Policy Info")]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string showInfo()
{
List<oInfo> lst = new List<oInfo>();
oInfo pi = new oInfo();
lst.name = "Mike";
lst.Add(pi);
lst.name = "John";
lst.Add(pi);
lst.name = "Susan";
lst.Add(pi);
return JsonConvert.SerializeObject(lst);
}

public class oInfo
{
public string name { get; set; }
}

No comments:

Post a Comment