首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

关于处理json解决思路

2012-09-11 
关于处理json[ { Text: 题目类型, Type: 选项, ChildList: [ { Text: 单选, Key: s$$1_T

关于处理json
[ { "Text": "题目类型", "Type": "选项", "ChildList": [ { "Text": "单选", "Key": "s$$1_Tag23$116131_1878" }, { "Text": "多选", "Key": "s$$1_Tag23$116131_1879" }, { "Text": "判断", "Key": "s$$1_Tag23$116131_1880" } ] }, { "Text": "内容分类", "Type": "选项", "ChildList": [ { "Text": "食品安全", "Key": "s$$1_Tag24$116131_1881" }, { "Text": "低碳环保", "Key": "s$$1_Tag24$116131_1882" }, { "Text": "神马类型", "Key": "s$$1_Tag24$116131_1883" } ] }, { "Text": "难易级别", "Type": "选项", "ChildList": [ { "Text": "一般", "Key": "s$$1_Tag25$116131_1884" }, { "Text": "普通", "Key": "s$$1_Tag25$116131_1885" }, { "Text": "困难", "Key": "s$$1_Tag25$116131_1886" } ] }, { "Text": "题目数量", "Type": "文本", "ChildList": [ { "Text": "题目数量", "Key": "s$$1_Text28$116125_λ" } ] }, { "Text": "题目", "Type": "文本", "ChildList": [ { "Text": "题目", "Key": "s$$1_Text29$116128_λ" } ] } ] 



这段json格式的我想分解成

{ "Text": "题目类型", "Type": "选项", "ChildList": [ { "Text": "单选", "Key": "s$$1_Tag23$116131_1878" }, { "Text": "多选", "Key": "s$$1_Tag23$116131_1879" }, { "Text": "判断", "Key": "s$$1_Tag23$116131_1880" } ] }

{ "Text": "内容分类", "Type": "选项", "ChildList": [ { "Text": "食品安全", "Key": "s$$1_Tag24$116131_1881" }, { "Text": "低碳环保", "Key": "s$$1_Tag24$116131_1882" }, { "Text": "神马类型", "Key": "s$$1_Tag24$116131_1883" } ] }

…………
怎么分解?

[解决办法]

JScript code
var text = [{ "Text": "题目类型", "Type": "选项", "ChildList": [{ "Text": "单选", "Key": "s$$1_Tag23$116131_1878" }, { "Text": "多选", "Key": "s$$1_Tag23$116131_1879" }, { "Text": "判断", "Key": "s$$1_Tag23$116131_1880"}] }, { "Text": "内容分类", "Type": "选项", "ChildList": [{ "Text": "食品安全", "Key": "s$$1_Tag24$116131_1881" }, { "Text": "低碳环保", "Key": "s$$1_Tag24$116131_1882" }, { "Text": "神马类型", "Key": "s$$1_Tag24$116131_1883"}] }, { "Text": "难易级别", "Type": "选项", "ChildList": [{ "Text": "一般", "Key": "s$$1_Tag25$116131_1884" }, { "Text": "普通", "Key": "s$$1_Tag25$116131_1885" }, { "Text": "困难", "Key": "s$$1_Tag25$116131_1886"}] }, { "Text": "题目数量", "Type": "文本", "ChildList": [{ "Text": "题目数量", "Key": "s$$1_Text28$116125_λ"}] }, { "Text": "题目", "Type": "文本", "ChildList": [{ "Text": "题目", "Key": "s$$1_Text29$116128_λ"}]}];    alert(text[0].Text);    alert(text[1].Text);。。。
------解决方案--------------------


JScript code
    $.each(text, function(i) {        alert(text[i].Text);    });
[解决办法]
探讨

如果是后台呢,
怎么操作

[解决办法]
System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer(); 


用这个处理具体用法百度下 .net JavaScriptSerializer

热点排行