0
은이 코드를 사용하고json 응답이 올바른지?
내가 IIS 및 과잉에이 서비스를 내 웹 서비스를 호스팅 할 때public static string myjson(bool a)
{
if (a == true)
{
RootObject o = new RootObject();
o.success = "true";
o.firstname = "anurag";
o.usertype = "admin";
o.userid = "123";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string d=serializer.Serialize(o);
return d;
}
else
{
errormessage o = new errormessage();
o.success = "false";
o.message = "invalid username or password";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string p=serializer.Serialize(o);
return p.ToString();
}
}
나는 응답이
{"checkuserResult":" {\"success\":\"true\",\"firstname\":\"anurag\",\"userid\":\"123\",\"usertype\":\"admin\"}"}
내가 수익으로 원하는 것은 바로 JSON 응답입니다 얻을
{"success":"true","firstname":"anurag","userid":"123","usertype":"admin"}
도와주세요.
json 문자열이 클라이언트에 반환되는 코드가 누락 된 것처럼 보입니다. 버그가있을 가능성이 있습니다. –
@ user3771185 \ "디버그 모드에서 볼 때.,하지만 출력은 유효한 json입니다. –
@ user3771185 운영 계약의 BodyStyle = WebMessageBodyStyle.Bare를 변경하십시오 - WCF –