gedmo(嵌套)树迭代为Jstree生成json

gedmo(嵌套)树迭代为Jstree生成json,json,doctrine-orm,metadata,jstree,Json,Doctrine Orm,Metadata,Jstree,我在理解如何将Gedmo树导出为Json以允许将其放入Jstree(V1.0)时遇到了一些问题。现在,Jstree由如下HTML提要提供: $htmlTree = $repository->childrenHierarchy( null, /* starting from root nodes */ false, /* true: load all children, false: only direct */ $options

我在理解如何将Gedmo树导出为Json以允许将其放入Jstree(V1.0)时遇到了一些问题。现在,Jstree由如下HTML提要提供:

    $htmlTree = $repository->childrenHierarchy(
        null, /* starting from root nodes */
        false, /* true: load all children, false: only direct */
        $options
    );
$options = array(
         'decorate' => true,
         'rootOpen' => '<ul>',
         'rootClose' => '</ul>',
         'childOpen' => '<li>',
         'childClose' => '</li>',
         'nodeDecorator' => function($node) {
            return '<a href='.$this->get('router')->generate('route_to_display_element', array('id' => $node['id'], true)).'">'.$node['name'].'</a>';
         }
    );
$htmlTree=$repository->childrenHierarchy(
null,/*从根节点开始*/
false,/*true:加载所有子项,false:仅直接加载*/
美元期权
);
$options=array(
“装饰”=>正确,
“rootOpen”=>“
    ”, “rootClose”=>“
”, “childOpen”=>“
  • ”, “childClose”=>“
  • ”, 'NodeCorator'=>函数($node){ 返回“”; } );
    我在后台使用Gedmo嵌套树实现。 但问题是,我需要在Jstree中插入一个ID属性,以实现未来的拖放功能,而我没有看到任何关于如何使用html的文档

    编辑: 我可以用给定的Json提要显示树,但生成它的迭代过程有缺陷:

    它应该显示什么(它在Html提要中显示什么):

    它实际显示的内容:


    有什么想法吗?谢谢你的阅读

    我设法使它与

      $tree = $repo->childrenHierarchy(
         $taxonomy->getRoot(), 
         false 
      );
    
     json_encode($tree)