`
y806839048
  • 浏览: 1120796 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

json组装(只要符合控件要求的格式即可,可以比控件要求的字段多)

阅读更多
//用对象是方式组装
//json组装(只要符合控件要求的格式即可,可以比控件要求的字段多)
//树形控件要树形json,其他控件,其他格式json都可以通过实体方式构建

样品:[
{ id:1,name:"上海市", open:true,
children: [
{ id:11,name:"徐汇",children: [{ id:111,name:"建国"},{ id:112,name:"沪闵"},{ id:113,name:"陇南"}]
},
      { id:12,name:"市中",
children:   [{ id:121,name:"昌平"},{ id:122,name:"永寿"},{ id:123,name:"尚文"},{ id:124,name:"卢湾"}
    ]
      }
  ]

}


]

用多了字段的实体:也可以用,结构一样下,字段可多,不可少。
[{"busip":"","id":1,"name":"徐汇","children":[{"busip":"","id":10,"name":"建国","children":[{"busip":"10.1.240.2","id":47,"name":"建国本地1","children":[],"mask":"","type":"3"},{"busip":"10.1.240.5","id":48,"name":"建国本地2","children":[],"mask":"","type":"3"},{"busip":"10.1.240.11","id":49,"name":"枫林街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.12","id":50,"name":"汇闲居街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.13","id":51,"name":"天平街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.15","id":52,"name":"瑞嘉街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.16","id":53,"name":"莱诗邸街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.17","id":54,"name":"徐虹街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.18","id":55,"name":"永嘉街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.20","id":56,"name":"徐镇街道站","children":[],"mask":"","type":"3"},{"busip":"10.1.240.21","id":57,"name":"天平街道站2","children":[],"mask":"","type":"3"}],"mask":"10.1.240","type":"2"},{"busip":"","id":11,"name":"沪闵","children":[{"busip":"","id":58,"name":"沪闵本地","children":[],"mask":"","type":"3"},{"busip":"","id":59,"name":"漕河泾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":60,"name":"田林街道站","children":[],"mask":"","type":"3"},{"busip":"","id":61,"name":"虹梅街道站","children":[],"mask":"","type":"3"},{"busip":"","id":62,"name":"康健街道站","children":[],"mask":"","type":"3"},{"busip":"","id":63,"name":"南宁街道站","children":[],"mask":"","type":"3"}],"mask":"10.2.240","type":"2"},{"busip":"","id":12,"name":"陇南","children":[{"busip":"","id":64,"name":"陇南本地","children":[],"mask":"","type":"3"},{"busip":"","id":65,"name":"凌云街道站","children":[],"mask":"","type":"3"},{"busip":"","id":66,"name":"长桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":67,"name":"龙华街道站","children":[],"mask":"","type":"3"},{"busip":"","id":68,"name":"中海瀛台街道站","children":[],"mask":"","type":"3"},{"busip":"","id":69,"name":"华泾街道站","children":[],"mask":"","type":"3"}],"mask":"10.4.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":2,"name":"虹口","children":[{"busip":"","id":13,"name":"广灵","children":[{"busip":"","id":70,"name":"广灵本地","children":[],"mask":"","type":"3"},{"busip":"","id":71,"name":"复城街道站","children":[],"mask":"","type":"3"},{"busip":"","id":72,"name":"乍浦街道站","children":[],"mask":"","type":"3"},{"busip":"","id":73,"name":"广中街道站","children":[],"mask":"","type":"3"},{"busip":"","id":74,"name":"欧阳街道站","children":[],"mask":"","type":"3"},{"busip":"","id":75,"name":"提篮桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":76,"name":"嘉兴街道站","children":[],"mask":"","type":"3"},{"busip":"","id":77,"name":"凉城街道站","children":[],"mask":"","type":"3"},{"busip":"","id":78,"name":"新港街道站","children":[],"mask":"","type":"3"},{"busip":"","id":79,"name":"曲阳街道站","children":[],"mask":"","type":"3"}],"mask":"10.14.240","type":"2"},{"busip":"","id":14,"name":"北外滩","children":[{"busip":"","id":80,"name":"北外滩本地","children":[],"mask":"","type":"3"}],"mask":"10.12.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":3,"name":"市中","children":[{"busip":"","id":15,"name":"昌平","children":[{"busip":"","id":81,"name":"昌平本地","children":[],"mask":"","type":"3"},{"busip":"","id":82,"name":"华山街道站","children":[],"mask":"","type":"3"},{"busip":"","id":83,"name":"宁街道站","children":[],"mask":"","type":"3"},{"busip":"","id":84,"name":"康定街道站","children":[],"mask":"","type":"3"},{"busip":"","id":85,"name":"石二街道站","children":[],"mask":"","type":"3"},{"busip":"","id":86,"name":"威海街道站","children":[],"mask":"","type":"3"},{"busip":"","id":87,"name":"延中街道站","children":[],"mask":"","type":"3"},{"busip":"","id":88,"name":"愚园街道站","children":[],"mask":"","type":"3"},{"busip":"","id":89,"name":"万航街道站","children":[],"mask":"","type":"3"},{"busip":"","id":90,"name":"广电街道站","children":[],"mask":"","type":"3"}],"mask":"10.10.240","type":"2"},{"busip":"","id":16,"name":"永寿","children":[{"busip":"","id":91,"name":"永寿本地","children":[],"mask":"","type":"3"},{"busip":"","id":92,"name":"金陵街道站","children":[],"mask":"","type":"3"},{"busip":"","id":93,"name":"金色家园街道站","children":[],"mask":"","type":"3"},{"busip":"","id":94,"name":"金色家园街道站2","children":[],"mask":"","type":"3"},{"busip":"","id":95,"name":"外滩街道站","children":[],"mask":"","type":"3"},{"busip":"","id":96,"name":"外滩街道站2","children":[],"mask":"","type":"3"},{"busip":"","id":97,"name":"市政府200号1","children":[],"mask":"","type":"3"},{"busip":"","id":98,"name":"市政府200号2","children":[],"mask":"","type":"3"}],"mask":"10.21.240","type":"2"},{"busip":"","id":17,"name":"尚文","children":[{"busip":"","id":99,"name":"南市本地","children":[],"mask":"","type":"3"},{"busip":"","id":100,"name":"半凇园街道站","children":[],"mask":"","type":"3"},{"busip":"","id":101,"name":"陈家桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":102,"name":"小东门街道站","children":[],"mask":"","type":"3"},{"busip":"","id":103,"name":"豫园街道站","children":[],"mask":"","type":"3"},{"busip":"","id":104,"name":"唐家湾街道站","children":[],"mask":"","type":"3"}],"mask":"10.22.240","type":"2"},{"busip":"","id":18,"name":"卢湾","children":[{"busip":"","id":105,"name":"卢湾本地","children":[],"mask":"","type":"3"},{"busip":"","id":106,"name":"打浦街道站","children":[],"mask":"","type":"3"},{"busip":"","id":107,"name":"皋兰街道站","children":[],"mask":"","type":"3"},{"busip":"","id":108,"name":"汇龙街道站","children":[],"mask":"","type":"3"},{"busip":"","id":109,"name":"马当街道站","children":[],"mask":"","type":"3"},{"busip":"","id":110,"name":"瑞金街道站","children":[],"mask":"","type":"3"},{"busip":"","id":111,"name":"五里街道站","children":[],"mask":"","type":"3"}],"mask":"10.23.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":4,"name":"杨浦","children":[{"busip":"","id":19,"name":"开鲁","children":[{"busip":"","id":112,"name":"开鲁本地","children":[],"mask":"","type":"3"},{"busip":"","id":113,"name":"工农三村街道站","children":[],"mask":"","type":"3"},{"busip":"","id":114,"name":"五角场镇(老)街道站","children":[],"mask":"","type":"3"},{"busip":"","id":115,"name":"五角场镇(新)街道站","children":[],"mask":"","type":"3"},{"busip":"","id":116,"name":"国和一村街道站","children":[],"mask":"","type":"3"},{"busip":"","id":117,"name":"五角场(老)街道站","children":[],"mask":"","type":"3"},{"busip":"","id":118,"name":"五角场(新)街道站","children":[],"mask":"","type":"3"},{"busip":"","id":119,"name":"新 湾城街道站","children":[],"mask":"","type":"3"},{"busip":"","id":120,"name":"东方国际水产中心街道站","children":[],"mask":"","type":"3"}],"mask":"10.15.240","type":"2"},{"busip":"","id":20,"name":"黄兴","children":[{"busip":"","id":121,"name":"黄兴本地","children":[],"mask":"","type":"3"},{"busip":"","id":122,"name":"延吉街道站","children":[],"mask":"","type":"3"},{"busip":"","id":123,"name":"长白街道站","children":[],"mask":"","type":"3"},{"busip":"","id":124,"name":"控 街道站","children":[],"mask":"","type":"3"},{"busip":"","id":125,"name":"四平街道站","children":[],"mask":"","type":"3"},{"busip":"","id":126,"name":" 浦街道站","children":[],"mask":"","type":"3"},{"busip":"","id":127,"name":"平凉街道站","children":[],"mask":"","type":"3"},{"busip":"","id":128,"name":"定海街道站","children":[],"mask":"","type":"3"}],"mask":"10.16.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":5,"name":"普陀","children":[{"busip":"","id":21,"name":"桂巷","children":[{"busip":"","id":129,"name":"桂巷本地","children":[],"mask":"","type":"3"},{"busip":"","id":130,"name":"白玉街道站","children":[],"mask":"","type":"3"},{"busip":"","id":131,"name":"真如街道站","children":[],"mask":"","type":"3"},{"busip":"","id":132,"name":"长风街道站","children":[],"mask":"","type":"3"},{"busip":"","id":133,"name":"曹杨街道站","children":[],"mask":"","type":"3"},{"busip":"","id":134,"name":"长征街道站","children":[],"mask":"","type":"3"},{"busip":"","id":135,"name":"桃浦街道站","children":[],"mask":"","type":"3"},{"busip":"","id":136,"name":"真光街道站","children":[],"mask":"","type":"3"},{"busip":"","id":137,"name":"星河世纪街道站","children":[],"mask":"","type":"3"}],"mask":"10.8.240","type":"2"},{"busip":"","id":22,"name":"中北","children":[{"busip":"","id":138,"name":"中北本地","children":[],"mask":"","type":"3"},{"busip":"","id":139,"name":"长寿街道站","children":[],"mask":"","type":"3"},{"busip":"","id":140,"name":"石泉街道站","children":[],"mask":"","type":"3"},{"busip":"","id":141,"name":"宜川街道站","children":[],"mask":"","type":"3"},{"busip":"","id":142,"name":"甘泉街道站","children":[],"mask":"","type":"3"},{"busip":"","id":143,"name":"捷城国际街道站","children":[],"mask":"","type":"3"}],"mask":"10.9.240","type":"2"},{"busip":"","id":23,"name":"靖边","children":[],"mask":"10.11.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":6,"name":"浦东","children":[{"busip":"","id":24,"name":"浦南","children":[{"busip":"","id":144,"name":"浦南本地","children":[],"mask":"","type":"3"},{"busip":"","id":145,"name":"东园街道站","children":[],"mask":"","type":"3"},{"busip":"","id":146,"name":"潍坊街道站","children":[],"mask":"","type":"3"},{"busip":"","id":147,"name":"塘桥街道站","children":[],"mask":"","type":"3"}],"mask":"10.19.240","type":"2"},{"busip":"","id":25,"name":"崮山","children":[{"busip":"","id":148,"name":"崮山本地","children":[],"mask":"","type":"3"},{"busip":"","id":149,"name":"龙威名邸街道站","children":[],"mask":"","type":"3"},{"busip":"","id":150,"name":"洋泾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":151,"name":"梅园街道站","children":[],"mask":"","type":"3"},{"busip":"","id":152,"name":"沪东街道站","children":[],"mask":"","type":"3"}],"mask":"10.20.240","type":"2"},{"busip":"","id":26,"name":"上南","children":[{"busip":"","id":153,"name":"上南本地","children":[],"mask":"","type":"3"},{"busip":"","id":154,"name":"南码头街道站","children":[],"mask":"","type":"3"},{"busip":"","id":155,"name":"周家渡街道站","children":[],"mask":"","type":"3"},{"busip":"","id":156,"name":"上钢街道站","children":[],"mask":"","type":"3"},{"busip":"","id":157,"name":"世博中心街道站","children":[],"mask":"","type":"3"},{"busip":"","id":158,"name":"两会_世博用户交换机","children":[],"mask":"","type":"3"},{"busip":"","id":159,"name":"两会_南码头用户交换机","children":[],"mask":"","type":"3"}],"mask":"10.24.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":7,"name":"闸北","children":[{"busip":"","id":27,"name":"南山","children":[{"busip":"","id":160,"name":"南山本地","children":[],"mask":"","type":"3"},{"busip":"","id":161,"name":"宝山街道站","children":[],"mask":"","type":"3"},{"busip":"","id":162,"name":"大宁街道站","children":[],"mask":"","type":"3"},{"busip":"","id":163,"name":"天目西街道站","children":[],"mask":"","type":"3"},{"busip":"","id":164,"name":"共和新街道站","children":[],"mask":"","type":"3"},{"busip":"","id":165,"name":"虬 街道站","children":[],"mask":"","type":"3"},{"busip":"","id":167,"name":"芷西街道站","children":[],"mask":"","type":"3"},{"busip":"","id":168,"name":"中兴街道站","children":[],"mask":"","type":"3"},{"busip":"","id":169,"name":"北站街道站","children":[],"mask":"","type":"3"},{"busip":"","id":170,"name":"青云街道站","children":[],"mask":"","type":"3"},{"busip":"","id":171,"name":"西藏北街道站","children":[],"mask":"","type":"3"}],"mask":"10.13.240","type":"2"},{"busip":"","id":28,"name":"闻喜","children":[{"busip":"","id":172,"name":"闻喜本地","children":[],"mask":"","type":"3"},{"busip":"","id":173,"name":"彭浦镇街道站","children":[],"mask":"","type":"3"},{"busip":"","id":174,"name":"临汾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":175,"name":"彭浦新村街道站","children":[],"mask":"","type":"3"}],"mask":"10.17.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":8,"name":"长宁","children":[{"busip":"","id":29,"name":"水城","children":[{"busip":"","id":176,"name":"水城本地","children":[],"mask":"","type":"3"},{"busip":"","id":177,"name":"仙霞街道站","children":[],"mask":"","type":"3"},{"busip":"","id":178,"name":"新世纪地下车库街道站","children":[],"mask":"","type":"3"},{"busip":"","id":179,"name":"天山街道站","children":[],"mask":"","type":"3"}],"mask":"10.3.240","type":"2"},{"busip":"","id":30,"name":"定西","children":[{"busip":"","id":180,"name":"定西本地","children":[],"mask":"","type":"3"},{"busip":"","id":181,"name":"虹桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":182,"name":"新华街道站","children":[],"mask":"","type":"3"},{"busip":"","id":183,"name":" 苏街道站","children":[],"mask":"","type":"3"},{"busip":"","id":184,"name":"华阳街道站","children":[],"mask":"","type":"3"}],"mask":"10.7.240","type":"2"},{"busip":"","id":31,"name":"临空","children":[{"busip":"","id":185,"name":"临空本地","children":[],"mask":"","type":"3"},{"busip":"","id":186,"name":"北新泾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":187,"name":"新泾镇街道站","children":[],"mask":"","type":"3"},{"busip":"","id":188,"name":"程桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":189,"name":"虹桥机场街道站","children":[],"mask":"","type":"3"}],"mask":"10.5.240","type":"2"}],"mask":"","type":"1"},{"busip":"","id":9,"name":"郊县","children":[{"busip":"","id":32,"name":"奉贤","children":[{"busip":"","id":190,"name":"奉贤本地","children":[],"mask":"","type":"3"},{"busip":"","id":191,"name":"海湾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":192,"name":"洪庙街道站","children":[],"mask":"","type":"3"},{"busip":"","id":193,"name":"邬桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":194,"name":"肖塘街道站","children":[],"mask":"","type":"3"},{"busip":"","id":195,"name":"庄行街道站","children":[],"mask":"","type":"3"},{"busip":"","id":196,"name":"玫瑰园街道站","children":[],"mask":"","type":"3"}],"mask":"10.32.240","type":"2"},{"busip":"","id":33,"name":"金山","children":[{"busip":"","id":197,"name":"金山本地","children":[],"mask":"","type":"3"},{"busip":"","id":198,"name":"兴塔街道站","children":[],"mask":"","type":"3"},{"busip":"","id":199,"name":"亭林街道站","children":[],"mask":"","type":"3"},{"busip":"","id":200,"name":"金山卫街道站","children":[],"mask":"","type":"3"},{"busip":"","id":201,"name":"枫泾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":202,"name":"石化街道站","children":[],"mask":"","type":"3"},{"busip":"","id":203,"name":"化工区街道站","children":[],"mask":"","type":"3"},{"busip":"","id":204,"name":"新城区街道站","children":[],"mask":"","type":"3"},{"busip":"","id":205,"name":"吕巷街道站","children":[],"mask":"","type":"3"}],"mask":"10.33.240","type":"2"},{"busip":"","id":34,"name":"闵行","children":[{"busip":"","id":206,"name":"闵行本地","children":[],"mask":"","type":"3"},{"busip":"","id":207,"name":"古美街道站","children":[],"mask":"","type":"3"},{"busip":"","id":208,"name":"龙柏街道站","children":[],"mask":"","type":"3"},{"busip":"","id":209,"name":"诸翟街道站","children":[],"mask":"","type":"3"},{"busip":"","id":210,"name":" 川街道站","children":[],"mask":"","type":"3"},{"busip":"","id":211,"name":"七宝街道站","children":[],"mask":"","type":"3"},{"busip":"","id":212,"name":"虹桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":213,"name":"颛桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":214,"name":"吴泾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":215,"name":"曹行街道站","children":[],"mask":"","type":"3"},{"busip":"","id":216,"name":"杜行街道站","children":[],"mask":"","type":"3"},{"busip":"","id":217,"name":"鲁汇街道站","children":[],"mask":"","type":"3"},{"busip":"","id":218,"name":"马桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":219,"name":"陈行街道站","children":[],"mask":"","type":"3"},{"busip":"","id":220,"name":"新曹行街道站","children":[],"mask":"","type":"3"}],"mask":"10.36.240","type":"2"},{"busip":"","id":35,"name":"松 ","children":[{"busip":"","id":221,"name":"松 本地","children":[],"mask":"","type":"3"},{"busip":"","id":222,"name":"佘山街道站","children":[],"mask":"","type":"3"},{"busip":"","id":223,"name":"图书馆街道站","children":[],"mask":"","type":"3"},{"busip":"","id":224,"name":"九亭街道站","children":[],"mask":"","type":"3"},{"busip":"","id":225,"name":"叶榭街道站","children":[],"mask":"","type":"3"},{"busip":"","id":226,"name":"泗泾镇街道站","children":[],"mask":"","type":"3"},{"busip":"","id":227,"name":"石湖荡街道站","children":[],"mask":"","type":"3"},{"busip":"","id":228,"name":"车墩镇街道站","children":[],"mask":"","type":"3"}],"mask":"10.34.240","type":"2"},{"busip":"","id":36,"name":"青浦","children":[{"busip":"","id":229,"name":"青浦本地","children":[],"mask":"","type":"3"},{"busip":"","id":230,"name":"金泽街道站","children":[],"mask":"","type":"3"},{"busip":"","id":231,"name":"赵屯街道站","children":[],"mask":"","type":"3"},{"busip":"","id":232,"name":"朱家角街道站","children":[],"mask":"","type":"3"},{"busip":"","id":233,"name":"练塘街道站","children":[],"mask":"","type":"3"},{"busip":"","id":234,"name":"徐泾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":235,"name":"赵巷街道站","children":[],"mask":"","type":"3"},{"busip":"","id":236,"name":"大盈街道站","children":[],"mask":"","type":"3"},{"busip":"","id":237,"name":"西岑街道站","children":[],"mask":"","type":"3"},{"busip":"","id":238,"name":"商塌街道站","children":[],"mask":"","type":"3"},{"busip":"","id":239,"name":"白鹤街道站","children":[],"mask":"","type":"3"}],"mask":"10.35.240","type":"2"},{"busip":"","id":37,"name":"嘉定","children":[{"busip":"","id":240,"name":"嘉定本地","children":[],"mask":"","type":"3"},{"busip":"","id":241,"name":"南翔街道站","children":[],"mask":"","type":"3"},{"busip":"","id":242,"name":"安亭街道站","children":[],"mask":"","type":"3"},{"busip":"","id":243,"name":"外冈街道站","children":[],"mask":"","type":"3"},{"busip":"","id":244,"name":" 桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":245,"name":"黄渡街道站","children":[],"mask":"","type":"3"},{"busip":"","id":246,"name":"娄塘街道站","children":[],"mask":"","type":"3"},{"busip":"","id":247,"name":"朱桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":248,"name":"菊园街道站","children":[],"mask":"","type":"3"}],"mask":"10.37.240","type":"2"},{"busip":"","id":38,"name":"宝山","children":[{"busip":"","id":249,"name":"宝山本地","children":[],"mask":"","type":"3"},{"busip":"","id":250,"name":"泗溏街道站","children":[],"mask":"","type":"3"},{"busip":"","id":251,"name":"顾村街道站","children":[],"mask":"","type":"3"},{"busip":"","id":252,"name":"罗店街道站","children":[],"mask":"","type":"3"},{"busip":"","id":253,"name":"罗泾街道站","children":[],"mask":"","type":"3"},{"busip":"","id":254,"name":"大场街道站","children":[],"mask":"","type":"3"},{"busip":"","id":255,"name":"盛桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":256,"name":"杨行街道站","children":[],"mask":"","type":"3"}],"mask":"10.39.240","type":"2"},{"busip":"","id":39,"name":"南汇","children":[{"busip":"","id":257,"name":"南汇本地","children":[],"mask":"","type":"3"},{"busip":"","id":258,"name":"航头街道站","children":[],"mask":"","type":"3"},{"busip":"","id":259,"name":"横沔街道站","children":[],"mask":"","type":"3"},{"busip":"","id":260,"name":"书院街道站","children":[],"mask":"","type":"3"},{"busip":"","id":261,"name":"新场街道站","children":[],"mask":"","type":"3"},{"busip":"","id":262,"name":"周浦街道站","children":[],"mask":"","type":"3"},{"busip":"","id":263,"name":"泥城街道站","children":[],"mask":"","type":"3"}],"mask":"10.42.240","type":"2"},{"busip":"","id":40,"name":"崇明","children":[{"busip":"","id":264,"name":"崇明本地","children":[],"mask":"","type":"3"},{"busip":"","id":265,"name":"新河街道站","children":[],"mask":"","type":"3"},{"busip":"","id":266,"name":"堡镇街道站","children":[],"mask":"","type":"3"},{"busip":"","id":267,"name":"庙镇街道站","children":[],"mask":"","type":"3"},{"busip":"","id":268,"name":"绿华街道站","children":[],"mask":"","type":"3"},{"busip":"","id":269,"name":"港沿街道站","children":[],"mask":"","type":"3"},{"busip":"","id":270,"name":"前哨街道站","children":[],"mask":"","type":"3"},{"busip":"","id":271,"name":"五效街道站","children":[],"mask":"","type":"3"},{"busip":"","id":272,"name":"陈家镇街道站","children":[],"mask":"","type":"3"},{"busip":"","id":273,"name":"长兴街道站","children":[],"mask":"","type":"3"}],"mask":"10.44.240","type":"2"},{"busip":"","id":41,"name":"临港","children":[{"busip":"","id":274,"name":"临港本地","children":[],"mask":"","type":"3"}],"mask":"10.45.240","type":"2"},{"busip":"","id":42,"name":"张  ","children":[{"busip":"","id":275,"name":"张 本地","children":[],"mask":"","type":"3"}],"mask":"10.41.240","type":"2"},{"busip":"","id":43,"name":"花木","children":[{"busip":"","id":276,"name":"花木本地","children":[],"mask":"","type":"3"},{"busip":"","id":277,"name":"北蔡街道站","children":[],"mask":"","type":"3"},{"busip":"","id":278,"name":"张 镇街道站","children":[],"mask":"","type":"3"}],"mask":"10.29.240","type":"2"},{"busip":"","id":44,"name":"高行","children":[{"busip":"","id":279,"name":"高行本地","children":[],"mask":"","type":"3"},{"busip":"","id":280,"name":"高东街道站","children":[],"mask":"","type":"3"},{"busip":"","id":281,"name":"高桥街道站","children":[],"mask":"","type":"3"},{"busip":"","id":282,"name":"外高桥街道站","children":[],"mask":"","type":"3"}],"mask":"10.46.240","type":"2"},{"busip":"","id":45,"name":"三林","children":[{"busip":"","id":283,"name":"三林本地","children":[],"mask":"","type":"3"},{"busip":"","id":284,"name":"云莲街道站","children":[],"mask":"","type":"3"}],"mask":"10.47.240","type":"2"},{"busip":"","id":46,"name":"唐镇","children":[{"busip":"","id":285,"name":"唐镇本地","children":[],"mask":"","type":"3"},{"busip":"","id":286,"name":"浦东机场街道站","children":[],"mask":"","type":"3"},{"busip":"","id":287,"name":"曹路街道站","children":[],"mask":"","type":"3"},{"busip":"","id":288,"name":"浦东机场镇街道站","children":[],"mask":"","type":"3"}],"mask":"10.48.240","type":"2"}],"mask":"","type":"1"}]





实体类用了个内部类:
/**
*
*/
package com.ces.zwww.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.ces.xarch.core.entity.LongIDEntity;

@Entity
@Table(name = "T_B_AREA")
public class Area extends LongIDEntity {

/** serialVersionUID(long):. */
private static final long serialVersionUID = -5967350210592855795L;

private String name;
private String mask;
private String remark;
private String address;

@Column(name="business_ip")
private String businessIp;

@Column(name="source_type")
private String sourceType;

@Column(name="parent_name")
private String parentName;

@Column(name="parent_id")
private Long parentId;

@Column(name="start_ip")
private String startIp;

@Column(name="end_ip")
private String endIp;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getMask() {
return mask;
}

public void setMask(String mask) {
this.mask = mask;
}

public String getRemark() {
return remark;
}

public void setRemark(String remark) {
this.remark = remark;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getBusinessIp() {
return businessIp;
}

public void setBusinessIp(String businessIp) {
this.businessIp = businessIp;
}

public String getSourceType() {
return sourceType;
}

public void setSourceType(String sourceType) {
this.sourceType = sourceType;
}

public String getParentName() {
return parentName;
}

public void setParentName(String parentName) {
this.parentName = parentName;
}

public Long getParentId() {
return parentId;
}

public void setParentId(Long parentId) {
this.parentId = parentId;
}

public String getStartIp() {
return startIp;
}

public void setStartIp(String startIp) {
this.startIp = startIp;
}

public String getEndIp() {
return endIp;
}

public void setEndIp(String endIp) {
this.endIp = endIp;
}

public class Tree {
private Long id;
private String name;
private String type;
private String mask;
private String busip;
private List<Tree> children;

public Tree(){

}

public Tree(Long id, String name, String type, String mask, String busip){
this.id = id;
this.name = name;
this.type = type;
this.mask = mask;
this.busip = busip;
this.children = new ArrayList<Area.Tree>();
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getMask() {
return mask;
}

public void setMask(String mask) {
this.mask = mask;
}

public String getBusip() {
return busip;
}

public void setBusip(String busip) {
this.busip = busip;
}

public List<Area.Tree> getChildren() {
return children;
}

public void setChildren(List<Area.Tree> children) {
this.children = children;
}

public void addChildren(Area.Tree tree) {
children.add(tree);
}
}
}
//用sql将查询结果树形化
select * from t_b_area t start with t.source_type = 1 connect by t.parent_id = prior t.id

//树形化之后用这个实体组装:

public List<Area.Tree> findByTree(){
List<Area.Tree> trees = new ArrayList<Area.Tree>();
List<Area> results = getDao().findByTree();
for (Area area : results) {
Area.Tree node = null;
if("1".equals(area.getSourceType())){
//内部类的应用方法
node = area.new Tree(area.getId(), area.getName(), area.getSourceType(), area.getMask(), area.getBusinessIp());
trees.add(node);
}else if("2".equals(area.getSourceType())){
node = getTreeNode(trees);
node.addChildren(area.new Tree(area.getId(), area.getName(), area.getSourceType(), area.getMask(), area.getBusinessIp()));
}else if("3".equals(area.getSourceType())){
node = getTreeNode(getTreeNode(trees).getChildren());
node.addChildren(area.new Tree(area.getId(), area.getName(), area.getSourceType(), area.getMask(), area.getBusinessIp()));
}
}
return trees;
}

//返回前台就是符合格式的树形json
public Object treeJs() throws FatalException {
Object result = getService().findByTreeAddSh();
this.setReturnData(result);
System.out.println(JsonUtil.objectToJsonStr(result));
return SUCCESS;
}
//此树形json放入树形结构的控件即可被数别,前面的树形控件也一样

<td style="width: 100px;padding-top: 10px;" align="right">
<label>告警区域:</label>
</td>
<td >
<cui:combotree id="area" name="area" width="160"  multiple="true" cascadeCheck="true" url="${ctx}/area!treeJs.json"></cui:combotree>
</td>
分享到:
评论

相关推荐

    Delphi_JSON控件及实例

    本文将深入探讨如何在Delphi中使用JSON控件以及相关的实例应用。 首先,我们要了解在Delphi中处理JSON的主要库:Indy的TIdJSON和System.JSON中的TJSONParser和TJSONObject等组件。这两个库提供了解析、生成和操作...

    jsonview json 高亮显示插件

    JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,被广泛用于Web应用程序之间传递数据。它基于JavaScript的一个子集,具有易于人阅读和编写,同时也易于机器解析和生成的特点。JSON格式通常由键值对...

    MFC使用json11解析JSON

    在IT行业中,MFC(Microsoft Foundation Classes)是一个由微软...总的来说,通过将json11库集成到MFC项目中,你可以轻松地实现JSON数据的解析和序列化,这对于与Web服务交互或处理本地存储的JSON格式数据非常有用。

    easyui纠正json格式日期列显示Demo

    症状:后台返回给页面的数据是Json格式的,其中的日期字段,在后台是“2012-11-10 12:18:00”这样的格式,json序列化后返回到前台页面就被转换成一个像 /Date(1419264000000)/ 的格式,导致easyUI无法解析这个字段。

    Ajax自动填充和字段验证器控件

    【Ajax自动填充和字段验证器控件】是Web开发中的一种技术实现,主要涉及Ajax、数据交换格式和数据模型的设计。Ajax(Asynchronous JavaScript and XML)允许网页在不重新加载整个页面的情况下与服务器交换数据并更新...

    .NET日期控件代码

    综上所述,.NET日期控件的使用涵盖了日期的格式化、事件处理、数据库交互等多个方面,理解并熟练运用这些知识点能够帮助开发者构建功能完善的日期选择功能。通过不断实践和学习,你可以更高效地处理日期相关的任务。

    jscalendar-日历控件;xtree-树型控件

    对于xtree,可能还需要熟悉JSON格式,因为树的数据通常以JSON形式传递。在实际项目中,可以将这两者与后端框架(如jQuery、AngularJS、React等)结合,实现更复杂的功能。 总的来说,jscalendar和xtree是JavaScript...

    使用json数据生成表单页面

    在Web开发中,动态生成表单页面是一种常见的需求,特别是在数据驱动的...通过查看源码,你可以更深入地了解如何将JSON数据与动态生成的表单页面相结合,这将有助于提升你在JavaScript开发中处理表单输入控件的能力。

    json转换为SQL server建表脚本

    JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,常用于Web服务和应用程序之间的数据传输,因为它易于阅读和编写,同时也易于机器解析和生成。SQL Server是一个强大的关系型数据库管理系统,广泛...

    vue + element ui工程,Tree 树形控件展示指定值,比如name

    在Vue.js框架中,Element UI库提供了一套丰富的UI组件,其中包括Tree树形控件。这个控件在数据展示和管理中非常常见,比如组织结构、文件目录等场景。本项目是一个基于Vue和Element UI的工程,专注于演示如何在Tree...

    jquery时间控件时分秒

    而"jquery时间控件时分秒"是jQuery的一个扩展插件,用于创建用户友好的时间选择器,帮助用户方便地输入或选择时间,通常用于表单中的时间输入字段。这种控件在许多场合都非常实用,比如预订系统、日程安排或时间跟踪...

    ASP.NET AJAX控件之AutoComplete

    这可以是SQL数据库、XML文件、Web服务或其他任何能返回JSON或XML格式数据的源。在ASP.NET中,可以通过使用SqlDataSource、XmlDataSource或WebServiceDataSource等控件来指定数据源。 2. 提供者:控件需要一个...

    微信开发日期控件

    这里我们主要关注的是"微信开发日期控件",它通常用于提高用户体验,让用户能方便地设定预约时间、创建日程或者填写表单中的日期相关字段。 微信并没有直接提供内置的日期控件,但开发者可以借助第三方库来实现这一...

    delphi ClientDataSet数据集转 JSON

    网上看了一些转的方法都有漏洞下面直接上代码

    多叉树结合JavaScript树形控件实现无限级树形结构(一种构建多级有序树形结构JSON(或XML)数据源的方法)

    1. 构建 JSON 数据源:树形控件需要将数据库中的层次数据转换成 JSON 格式的字符串,以便在客户端动态生成树形结构。 2. Ext JS 框架:这是一种富客户端开发框架,其 TreePanel 组件常用于实现树形视图,支持 ...

    Ztree后台拼接Json

    在IT行业中,ZTree是一款广泛使用的JavaScript树形控件,尤其在数据展示和管理界面中。这个场景中提到的“Ztree后台拼接Json”主要指的是如何在服务器端(后台)处理并组合JSON数据,以便于ZTree前端组件能够正确...

    Delphi报表控件

    4. **分页和布局管理**:为了适应不同的输出需求,报表控件会提供分页功能,确保长报表可以适当地分布在多页上。同时,布局管理功能允许调整各元素的相对位置,以适应不同的打印和屏幕显示环境。 5. **图表集成**:...

    asp.net Calendar控件实现日程显示

    在本项目中,我们看到这个控件被用来显示日程事件,通过结合jQuery、AJAX以及JSON技术,实现了动态地获取和更新日程信息。下面我们将详细探讨这些知识点。 1. **ASP.NET Calendar控件** ASP.NET Calendar控件是一...

    多叉树结合JavaScript树形控件实现无限级树形菜单(一种构建多级有序树形结构JSON(或XML)数据源的方法).pdf

    JavaScript树形控件,如JQuery、Dojo、Yahoo UI、Ext JS等,通常利用AJAX技术从服务器获取数据,数据源通常是JSON或XML格式。本文以Ext JS为例,探讨如何构建无限级树形菜单,即处理数据库中无限层级的数据,并将其...

    extjs 5 combogrid控件

    Store可以配置远程数据源,支持JSON、XML、CSV等多种格式。 2. **模板配置**:用户可以自定义显示模板,以决定在下拉列表中如何呈现每一行数据,比如显示多个字段的组合或者添加图标等。 3. **筛选搜索**:...

Global site tag (gtag.js) - Google Analytics