【发布时间】:2013-08-15 08:51:01
【问题描述】:
我想在 mvc asp .net 网络服务中编写 http 帖子,该服务从 android 应用程序获取 BasicNameValuePair 返回一个 Json 数组。
你能帮帮人吗?
【问题讨论】:
标签: android asp.net asp.net-mvc json.net
我想在 mvc asp .net 网络服务中编写 http 帖子,该服务从 android 应用程序获取 BasicNameValuePair 返回一个 Json 数组。
你能帮帮人吗?
【问题讨论】:
标签: android asp.net asp.net-mvc json.net
[HttpPost]
[WebMethod(EnableSession = true)]
public string change()
{
int i=Request["id"] != null;
System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(oList);
return sJSON;
}
【讨论】:
不完全确定您的要求,但听起来您想要一个接收键值对列表并返回 json 的端点。可以这样做:
[HttpPost]
public JsonResult MyMethod (IDictionary<string, object> inputParam) {
var myArray = GetArrayFromSomewhere(inputParam); //possibly another webservice or database
return Json(myArray, JsonRequestBehaviour.DenyGet);
}
【讨论】: