SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `dictionary`
-- ----------------------------
DROP TABLE IF EXISTS `dictionary`;
CREATE TABLE `dictionary` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `topic_id` int(11) DEFAULT NULL COMMENT '主标题ID',
  `item_name` varchar(100) NOT NULL COMMENT '值',
  `parent_id` int(11) DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL COMMENT '说明',
  `the_sort` int(11) DEFAULT '1000' COMMENT '排序',
  PRIMARY KEY (`id`),
  KEY `ix_category_id` (`topic_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=586 DEFAULT CHARSET=utf8 COMMENT='数据字典项';-- ----------------------------
-- Records of `dictionary`
-- ----------------------------
INSERT INTO `dictionary` VALUES ('303', '4', '医学', null, null, '1000');
INSERT INTO `dictionary` VALUES ('304', '4', '外科', '303', null, '1000');
INSERT INTO `dictionary` VALUES ('305', '4', '内科', '303', null, '1000');
INSERT INTO `dictionary` VALUES ('314', '4', '中医类', '303', null, '1000');
INSERT INTO `dictionary` VALUES ('315', '4', '药剂类', '303', null, '1000');
INSERT INTO `dictionary` VALUES ('316', '4', '普外科', '304', null, '1000');
INSERT INTO `dictionary` VALUES ('319', '4', '神经外科', '304', null, '1000');
INSERT INTO `dictionary` VALUES ('325', '4', '消化内科', '305', null, '1000');
INSERT INTO `dictionary` VALUES ('371', '4', '中医医疗', '314', null, '1000');
INSERT INTO `dictionary` VALUES ('373', '4', '中药', '315', null, '1000');java如何将上面的数据 转换成json格式,用于tree生成,parent_id 是上下级关联ID结果如下:
[
    {text:医学,children:[
        {text:外科,children:[
            {text:普外科,leaf:true},
            {text:神经外科,leaf:true}
        ]},
        {text:内科,children:[
            {text:消化内科,leaf:true}
        ]},
        ........内容同上
    ]}
]求实现的例子,java程序 or 其它