1
realityone 2014-11-22 20:18:10 +08:00 1
children那里不是一个array吗。。
|
2
xarrow OP @realityone 怎么写?
|
3
realityone 2014-11-22 22:43:49 +08:00 1
@xarrow .net不熟。。
就是children那里赋一个对应的list给他啊,list里面好像还有dic。。 |
4
xarrow OP @realityone 正在考虑用Python~
|
5
realityone 2014-11-22 22:53:09 +08:00 1
@xarrow
py的话。。 {'name': 'lisi', 'children': [{'name': 'mail', 'children': [{'name': '[email protected]'}]}, {'name': 'password', 'children': [{'name': 'lisi'}]}]} |
6
mkeith 2014-11-23 00:42:36 +08:00
楼主要干什么啊?
|
7
cdxem713 2014-11-23 01:50:18 +08:00 via iPhone 1
json.net的话,简单的就是一个dictinary<string,object>(); children那个键值用list<dictinary<string,object>>();最后JSON.serializeObject就可以了
|
9
cdxem713 2014-11-23 14:21:55 +08:00 1
@xarrow
var mainJson = new Dictionary<string, object>(); mainJson.Add("name","lisi"); var mainChilds = new List<Dictionary<string, object>>(); var sub1 = new Dictionary<string, object>(); sub1.Add("name","mail"); var sub1Childs = new List<Dictionary<string, object>>(); sub1Childs.Add(new Dictionary<string, object> { { "name", "[email protected]" } }); sub1.Add("children",sub1Childs); var sub2 = new Dictionary<string, object>(); sub2.Add("name", "password"); var sub2Childs = new List<Dictionary<string, object>>(); sub2Childs.Add(new Dictionary<string, object> { { "name", "lisi" } }); sub2.Add("children",sub2Childs); mainChilds.Add(sub1); mainChilds.Add(sub2); mainJson.Add("children",mainChilds); Console.WriteLine(JsonConvert.SerializeObject(mainJson)); Console.ReadLine(); |
10
xarrow OP @cdxem713 臣妾真的不懂json啊!!啥玩意儿这是.....
大牛,跪求完整处理代码~~ { "name": "key_word", "children": [ { "name": "zhangsan", "children": [ { "name": "mail", "children": [ {"name": "[email protected]"} ] }, { "name": "password", "children": [ {"name": "12345678"} ] } ] }, { "name": "lisi", "children": [ { "name": "mail", "children": [ {"name": "[email protected]"} ] }, { "name": "password", "children": [ {"name": "lisi"} ] } ] } ] } ////////////////////////////////////////////////////////////// 结构 |-----zhangsan-| | |------password key_word----| |------mail |-----lisi-| | |------password |-----wangwu | |-----..... |
11
xarrow OP |
13
cdxem713 2014-11-23 23:03:51 +08:00
@xarrow GOD,你这JSON好奇葩,如果是自己造的格式,最好还是改下,像mail,password这种都可以用作键的,你给我个邮件地址,我等下写了传给你吧
|
14
cdxem713 2014-11-23 23:08:53 +08:00 1
@xarrow
{ "name":"key_word", "children":[ { "name":"zhangsan", "mail":"[email protected]", "password":"12345678" }, { "name":"lisi", "mail":"[email protected]", "password":"12345678" } ] } 这个格式我觉得会好些 |