3
asmx WebService에서 내 JSON 응답에 __type
을 제외하는 방법을 결정하려고합니다.asp.net 2.0 asmx WebService JSON 응답에서 __type 제외
내가 반환하는 클래스는 다음과 같이 구성됩니다.
public class MyClassName
{
private string _item1 = string.Empty;
private string _item2 = string.Empty;
public string item1 = { get { return _item1; } set { _item1 = value; } }
public string item2 = { get { return _item2; } set { _item2 = value; } }
}
public class MyClassName_List : List<MyClassName>
{
public MyClassName_List() {}
}
그런 다음 채워진 인스턴스 MyClassName_List
을 반환하는 데이터 액세스 레이어와 비즈니스 로직 레이어가 있습니다. 내 WebMethod는 다음과 같이 설정됩니다.
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class MyClassName_WebService : System.Web.Services.WebService
{
[WebMethod]
public MyClassName_List GetList()
{
return MyClassName_List_BusinessLogicLayer.GetList();
}
}
JSON 개체 반환 값은 다음과 같이 구성됩니다.
[
{
item1: "item1-1 text",
item2: "item1-2 text",
__type: "NamespaceUsed.MyClassName"
},
{
item1: "item2-1 text",
item2: "item2-2 text",
__type: "NamespaceUsed.MyClassName"
},
]
다음과 같이 JSON 객체를 반환하고 싶습니다.
[
{
item1: "item1-1 text",
item2: "item1-2 text"
},
{
item1: "item2-1 text",
item2: "item2-2 text"
}
]
나는 here에서 제안을 시도,하지만 난 그것을 제대로 구현할 수없는 것. 이것에 대한 도움이 많이 감사합니다!
나는 2 시간 동안 검색을 해왔고,이 대답은 깜박임으로 해결되었습니다! 감사! – StijnSpijker
도움이 되니 기쁩니다! 문제가 있으면 알려주세요. 나는이 문제를 아무런 문제없이 꽤 오랫동안 사용 해왔다! – JoeFletch