How can I just only return json string without xml tag?
I trid
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld()
{
return "Hello World";
}
not working.
create object
public class LoginError
{
public string login { get; set; }
public string error_code { get; set; }
}
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string login(){
LoginError l = new LoginError();
l.login = "fail";
l.error_code = "1";
return new JavaScriptSerializer().Serialize(l);
}
not working
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string Tester()
{
JavaScriptSerializer ser = new JavaScriptSerializer();
var jsonData = new
{
total = 1,
page = 1,
records = 3,
rows = new[]{
new {id = 1, cell = new[] {"1", "-7", "Is this a good question?", "yay"}},
new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?", "yay"}},
new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?", "yay"}}
}
};
return ser.Serialize(jsonData);
}
still fail.....
can someone tell me how to do it?
I have to use this service for the android app, but it keeps showing the xml tag...