前台一个json数组:
var jsonObj2={persons:[{name:"jordan",sex:"m",age:"40"},
{name:"bryant",sex:"m",age:"28"},
{name:"McGrady",sex:"m",age:"27"}
]};
到后台保存时我怎么把这个json数组转化为后台的数据
也就是到后台取到这个json数组的值
var jsonObj2={persons:[{name:"jordan",sex:"m",age:"40"},
{name:"bryant",sex:"m",age:"28"},
{name:"McGrady",sex:"m",age:"27"}
]};
到后台保存时我怎么把这个json数组转化为后台的数据
也就是到后台取到这个json数组的值
解决方案 »
- 关于datetimepicker时间段查询
- webserver和api
- 事务TransactionScope() 使用了提交Commit()还需要Complete()吗?
- 急死了。下拉菜单问题!!!!!!!!!!
- 100分,My97日期控件My97DatePicker4.0正式版(跨框架,跨浏览器,带时间,自定义格式,多语言,日期限制,周显示,动态皮肤等),有详细演示和使用说明
- 在VS2005调试正常,在IIS上调试出错,怎么回事??
- 懂数据岛技术的同志进来帮帮忙,没分了,多多照顾
- 在线急等!!关于导出到Excel的问题
- 有办法一次性注册所有在页面上将使用的用户控件吗?
- 请问用IIS7.0的只有winsever2003吗
- 每个面页都有一个<title>标签,比如放网站名称,如何将网站定义成公共变量
- datalist获取值
如果没有, 那就优先{persons:[{ 跟最后一个]} 去掉,
然后使用},{ split 开, 再一个字符串 分隔. 分隔... 这是我的想法..
注意:这个是将后台数据转成Json数组,你反过来就是的了!
//构建JSon对象
StringWriter text = new StringWriter();
JsonWriter json = new JsonWriter(text);
json.Formatting = Formatting.Indented;
json.WriteStartArray();
for (int i = 0; i < data.Tables[0].Rows.Count; i++)
{
DataRow currRow = data.Tables[0].Rows[i];
json.WriteStartObject();
//简历ID
json.WritePropertyName("rid");
json.WriteValue(Convert.ToInt32(currRow["id"]));
//求职者姓名
PersonalInfo pinfo = new PersonalInfo();
int mid = Convert.ToInt32(currRow["mid"]);
DataSet temp = pinfo.QueryPersonalInfoByUid(mid);
json.WritePropertyName("realName");
json.WriteValue(temp.Tables[0].Rows[0]["realName"].ToString());
//求职者ID
json.WritePropertyName("mid");
json.WriteValue(mid.ToString());
//性别
int str_sex = Convert.ToInt32(temp.Tables[0].Rows[0]["sex"]);
json.WritePropertyName("sex");
if (str_sex == 1) json.WriteValue("男");
else json.WriteValue("女");
//年龄
DateTime birthday = Convert.ToDateTime(temp.Tables[0].Rows[0]["birthday"]);
int age = DateTime.Now.Year - birthday.Year;
json.WritePropertyName("age");
json.WriteValue(age.ToString());
//学历
string str_education = temp.Tables[0].Rows[0]["education"].ToString();
item = category.QueryCategoryById(str_education);
json.WritePropertyName("education");
json.WriteValue(item.Tables[0].Rows[0]["cName"].ToString());
//行业职位
string str_workIndustry = currRow["workIndustry"].ToString();
item = category.QueryCategoryById(str_workIndustry);
string industry_job = item.Tables[0].Rows[0]["cName"].ToString() + "-";
string str_workJob = currRow["workJob"].ToString();
item = category.QueryCategoryById(str_workJob);
industry_job += item.Tables[0].Rows[0]["cName"].ToString();
json.WritePropertyName("job");
json.WriteValue(industry_job);
//工作经验
string str_workAge = currRow["workAge"].ToString();
item = category.QueryCategoryById(str_workAge);
json.WritePropertyName("workAge");
json.WriteValue(item.Tables[0].Rows[0]["cName"].ToString());
//简历公开程度
string str_openness = currRow["openness"].ToString();
item = category.QueryCategoryById(str_openness);
json.WritePropertyName("openness");
json.WriteValue(item.Tables[0].Rows[0]["cName"].ToString());
json.WriteEndObject();
}
json.WriteEndArray();
type: "POST",
url: "handler.ashx",
data: "",
dataType:"json",
..
}); context.Request.Form["name"];