关于JSON三层遍历的问题

请问这个JOSN三层怎么分别遍历出来

 [{"id":"1","pid":"0","name":"一级菜单","_child":[{"id":"2","pid":"1","name":"二级菜单","_child":[{"id":"39","pid":"2","name":"集团CRM"},{"id":"40","pid":"2","name":"三级菜单A"},{"id":"41","pid":"2","name":"三级菜单B"},{"id":"42","pid":"2","name":"三级菜单C"},{"id":"43","pid":"2","name":"三级菜单D"},{"id":"44","pid":"2","name":"三级菜单E"},{"id":"45","pid":"2","name":"三级菜单F"},{"id":"46","pid":"2","name":"三级菜单G"}]}]}]

2个回答

     import java.util.List;
     public class JsonRootBean {

    private String id;
    private String pid;
    private String name;
    private List<_child> _child;
    public void setId(String id) {
         this.id = id;
     }
     public String getId() {
         return id;
     }

    public void setPid(String pid) {
         this.pid = pid;
     }
     public String getPid() {
         return pid;
     }

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

    public void set_child(List<_child> _child) {
         this._child = _child;
     }
     public List<_child> get_child() {
         return _child;
     }

    }

    public class _child {

    private String id;
    private String pid;
    private String name;
    public void setId(String id) {
         this.id = id;
     }
     public String getId() {
         return id;
     }

    public void setPid(String pid) {
         this.pid = pid;
     }
     public String getPid() {
         return pid;
     }

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

    }
    import java.util.List;

    public class _child {

    private String id;
    private String pid;
    private String name;
    private List<_child> _child;
    public void setId(String id) {
         this.id = id;
     }
     public String getId() {
         return id;
     }

    public void setPid(String pid) {
         this.pid = pid;
     }
     public String getPid() {
         return pid;
     }

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

    public void set_child(List<_child> _child) {
         this._child = _child;
     }
     public List<_child> get_child() {
         return _child;
     }

    }

如果是android 就是JSONObject手动解析就好了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问