日期:2014-05-17 浏览次数:20472 次
var prsonjosn = { 'Id': '', 'Name': '','Title': '' };
prsonjosn.Id = mfi_id;
prsonjosn.Title = titleTemp; //title
prsonjosn.Name = mfi_name; //厂商名称
var jsonStr = "";
$.each(prsonjosn, function (i, n) {
jsonStr = jsonStr + "\"" + i + "\":" + "\"" + n + "\","
});
if (jsonStr == "") {
art.alert("失败");
return true;
}
jsonStr = jsonStr.substring(0, jsonStr.length - 1);
jsonStr = "{" + jsonStr + "}";
alert(jsonStr);//检测过,数据内容格式都正确的
$.post("AddOne.aspx?StrJson=" + { JsonStr: jsonStr },
public class YlObj
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Title { get; set; }
public YlObj(int Id_, string Name_, string Title_)
{
Id = Id_;
Name = Name_;
Title = Title_;
}
}
public class Json
{
public static string ToJsJson(object item)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(item.GetType());
using(MemoryStream ms=new MemoryStream())
{
serializer.WriteObject(ms, item);
StringBuilder sb = new StringBuilder();
sb.Append(Encoding.UTF8.GetString(ms.ToArray()));
return sb.ToString();
&nb