bootstrap-treeview C# 后台怎么拼json字符串

 var defaultData = [
              {
                  text: 'Parent 1',
                  href: '#parent1',
                  tags: ['4'],
                  nodes: [
                    {
                        text: 'Child 1',
                        href: '#child1',
                        tags: ['2'],
                        nodes: [
                          {
                              text: 'Grandchild 1',
                              href: '#grandchild1',
                              tags: ['0']
                          },
                          {
                              text: 'Grandchild 2',
                              href: '#grandchild2',
                              tags: ['0']
                          }
                        ]
                    },
                    {
                        text: 'Child 2',
                        href: '#child2',
                        tags: ['0']
                    }
                  ]
              },
              {
                  text: 'Parent 2',
                  href: '#parent2',
                  tags: ['0']
              },
              {
                  text: 'Parent 3',
                  href: '#parent3',
                  tags: ['0']
              },
              {
                  text: 'Parent 4',
                  href: '#parent4',
                  tags: ['0']
              },
              {
                  text: 'Parent 5',
                  href: '#parent5',
                  tags: ['0']
              }
            ];

 

 

后台如何返回这样的json

Newtonsoft.Json 挺好用的

List + 实体 写好后直接用json工具序列化成json字符串返回就可以了