JSON 문자열을 매개 변수로받는 웹 서비스가 있습니다. 내 웹 메서드의 매개 변수가 제네릭 형식의 '개체'일 때만 성공적으로 보낼 수있었습니다.어떻게이 JSON 객체를 직렬화 할 수 있습니까?
이 일반 개체를 문자열이나 사용자 지정 개체로 serialize 할 수 있습니까? 이 메소드의 매개 변수 유형을 수정해야합니까? 어떤 도움이라도 굉장합니다.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string StoreDataOut(object json)
{
//serialization magic
}
이이 웹 메소드에 전달되는 테스트 JSON입니다 : 여기
는 웹 방법{
"uid":"1234abcd",
"application":"Application Name",
"eventName":null,
"clienttoken":"Test Client",
"version":"1.0.0",
"datetime":"1/1/2011 12:00 AM",
"data":[
{
"id":"alpha_123",
"question":"ronunciations in pre-classical times or in non-Attic dialects. For det",
"answer":"nunciations "
},
{
"id":"beta_456",
"question":"official documents such as laws an",
"answer":"or modif"
},
{
"id":"gamma_789",
"question":" maintained or modified slightly to fit Greek phonology; thus, ?",
"answer":"iation of Attic"
},
{
"id":"delta_098",
"question":"econstructed pronunciation of Attic in the late 5th an",
"answer":"unciation of "
},
{
"id":"epsilon_076",
"question":"erent stylistic variants, with the descending tail either going straight down o",
"answer":"Whole bunch"
},
{
"id":"zeta_054",
"question":"rough breathing when it begins a word. Another diacritic use",
"answer":"other dia"
}
]
}
그냥 작동할까요?! 멋지다 .. 아프다. – Nick
이것은 매우 가까이에 도착하지만 .. "데이터"목록에 채워지지 않습니다. – Nick
신경 쓰지 마 :) 감사합니다. .. asp.net이 그런 속성을 매핑하는 것을 전혀 몰랐습니다. – Nick