【发布时间】:2011-02-24 23:25:16
【问题描述】:
我有一个接收 JSON 字符串作为参数的 Web 服务。只有当我的 Web 方法的参数是泛型类型“对象”时,我才能成功发送它。
我可以将此通用对象序列化为字符串或自定义对象吗?我需要修改这个方法的参数类型吗?任何帮助都会很棒。
这是网络方法:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string StoreDataOut(object json)
{
//serialization magic
}
这是传递给此 Web 方法的测试 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"
}
]
}
【问题讨论】:
标签: javascript asp.net ajax web-services jquery