在不确定的情况循环嵌套的JSON怎么解析? 5C

结构大概是这样的
下面是模拟数据 要用"chian" 字段写一个
{
"datas" : [ {
"payAmount" : 0,
"area" : "滁州市",
"userId" : "3638b61f7ef74d95ad6c14d8bc0644ff",
"chainCount" : 3,
"seq" : 1,
"userName" : "还是收到",
"receiveAmount" : 7.00,
"chian" : [ {
"amount" : 7.00,
"node" : 1,
"area" : "",
"debtorName" : "还是",
"accountId" : "AC20180810000616",
"debtorId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"creditorId" : "3638b61f7ef74d95ad6c14d8bc0644ff",
"children" : [ {
"amount" : 6.00,
"node" : 2,
"area" : "",
"debtorName" : "士大夫",
"accountId" : "AC20180907000652",
"debtorId" : "265581f4b83540a09cd8fba8797e7065",
"creditorId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"children" : [ ],
"creditorName" : "还是"
}, {
"amount" : 2.00,
"node" : 2,
"area" : "",
"debtorName" : "海阔天空",
"accountId" : "AC20180912000657",
"debtorId" : "a41dac80eaf940d58bcda3fe42faaaa3",
"creditorId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"children" : [ {
"amount" : 4.00,
"node" : 3,
"area" : "",
"debtorName" : "士大夫",
"accountId" : "AC20180907000651",
"debtorId" : "265581f4b83540a09cd8fba8797e7065",
"creditorId" : "a41dac80eaf940d58bcda3fe42faaaa3",
"children" : [ ],
"creditorName" : "海阔天空"
} ],
"creditorName" : "还是"
}, {
"amount" : 90000000.00,
"node" : 2,
"area" : "",
"debtorName" : "士大夫",
"accountId" : "AC20180824000639",
"debtorId" : "265581f4b83540a09cd8fba8797e7065",
"creditorId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"children" : [ ],
"creditorName" : "还是"
} ],
"creditorName" : "还是收到"
} ],
"rongziAll" : 90000008.00
}, {
"financeAmount" : 0,
"payAmount" : 0,
"area" : "抚顺市",
"userId" : "3a33493363594bdfaa304586ab62668c",
"chainCount" : 0,
"seq" : 2,
"userName" : "A",
"receiveAmount" : 0,
"chian" : "",
"rongziAll" : 0
}, {
"payAmount" : 0,
"area" : "佳木斯市",
"userId" : "c92fce2d51154fc597421c0c2d4f9171",
"chainCount" : 1,
"seq" : 3,
"userName" : "阿甘船运有限公司",
"receiveAmount" : 1500000.00,
"chian" : [ {
"amount" : 1500000.00,
"node" : 1,
"area" : "",
"debtorName" : "澳洲太和矿业有限公司",
"accountId" : "AC20180412000452",
"debtorId" : "1acc2644a97541e5a9291120e379f416",
"creditorId" : "c92fce2d51154fc597421c0c2d4f9171",
"children" : [ ],
"creditorName" : "阿甘船运有限公司"
} ],
"rongziAll" : 1500000.00
}, {
"financeAmount" : 0,
"payAmount" : 0,
"area" : "南昌市",
"userId" : "1260d446161c4d7c8220e5addccc30ed",
"chainCount" : 0,
"seq" : 4,
"userName" : "个人附件阿萨德",
"receiveAmount" : 0,
"chian" : "",
"rongziAll" : 0
}, {
"financeAmount" : 0,
"payAmount" : 0,
"area" : "伊犁哈萨克自治州",
"userId" : "3fdc805022814024872428a5cefc9793",
"chainCount" : 0,
"seq" : 5,
"userName" : "贺声耀",
"receiveAmount" : 0,
"chian" : "",
"rongziAll" : 0
}, {
"payAmount" : 7.00,
"area" : "滁州市",
"userId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"chainCount" : 3,
"seq" : 6,
"userName" : "还是",
"receiveAmount" : 90000008.00,
"chian" : [ {
"amount" : 6.00,
"node" : 1,
"area" : "",
"debtorName" : "士大夫",
"accountId" : "AC20180907000652",
"debtorId" : "265581f4b83540a09cd8fba8797e7065",
"creditorId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"children" : [ ],
"creditorName" : "还是"
}, {
"amount" : 2.00,
"node" : 1,
"area" : "",
"debtorName" : "海阔天空",
"accountId" : "AC20180912000657",
"debtorId" : "a41dac80eaf940d58bcda3fe42faaaa3",
"creditorId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"children" : [ {
"amount" : 4.00,
"node" : 2,
"area" : "",
"debtorName" : "士大夫",
"accountId" : "AC20180907000651",
"debtorId" : "265581f4b83540a09cd8fba8797e7065",
"creditorId" : "a41dac80eaf940d58bcda3fe42faaaa3",
"children" : [ ],
"creditorName" : "海阔天空"
} ],
"creditorName" : "还是"
}, {
"amount" : 90000000.00,
"node" : 1,
"area" : "",
"debtorName" : "士大夫",
"accountId" : "AC20180824000639",
"debtorId" : "265581f4b83540a09cd8fba8797e7065",
"creditorId" : "43ded7a2d9b647d3bd1d8a5f7125dab4",
"children" : [ ],
"creditorName" : "还是"
} ],
"rongziAll" : 90000008.00
}, {
"financeAmount" : 0,
"payAmount" : 1500000.00,
"area" : "长春市",
"userId" : "1acc2644a97541e5a9291120e379f416",
"chainCount" : 0,
"seq" : 7,
"userName" : "澳洲太和矿业有限公司",
"receiveAmount" : 0,
"chian" : "",
"rongziAll" : 0
}, {
"financeAmount" : 0,
"payAmount" : 0,
"area" : "怀化市",
"userId" : "7869179be7b74951994de20448970fe3",
"chainCount" : 0,
"seq" : 8,
"userName" : "Shhshs",
"receiveAmount" : 0,
"chian" : "",
"rongziAll" : 0
}, {
"payAmount" : 2.00,
"area" : "贵阳市",
"userId" : "a41dac80eaf940d58bcda3fe42faaaa3",
"chainCount" : 1,
"seq" : 9,
"userName" : "海阔天空",
"receiveAmount" : 4.00,
"chian" : [ {
"amount" : 4.00,
"node" : 1,
"area" : "",
"debtorName" : "士大夫",
"accountId" : "AC20180907000651",
"debtorId" : "265581f4b83540a09cd8fba8797e7065",
"creditorId" : "a41dac80eaf940d58bcda3fe42faaaa3",
"children" : [ ],
"creditorName" : "海阔天空"
} ],
"rongziAll" : 4.00
}, {
"financeAmount" : 0,
"payAmount" : 90000010.00,
"area" : "澳门",
"userId" : "265581f4b83540a09cd8fba8797e7065",
"chainCount" : 0,
"seq" : 10,
"userName" : "士大夫",
"receiveAmount" : 0,
"chian" : "",
"rongziAll" : 0
} ],
"result" : "success",
"count" : 10,
"page" : "1",
"msg" : "0"
}

7个回答

可以用递归,也可以不用。递归简单,就不说了。
不用递归伪代码如下:

当前层次 = 1;
do
{
n = 遍历层次为1的,添加到列表,返回数量
当前层次++;
} while (n > 0);

像这种情况,一个bean是解决不了的children 是个循环体,不确定是否存在,所以用的时候判断一下是否是null,不为null再判断下层如此就ok了

手动解析,只要是解析数组之前先判断size是不是为0就可以了,用手动解析应该是比较快的方法

我真是闲的无聊

代码

package com.vzoom.ath.wsc.json;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.List;

import com.alibaba.fastjson.JSON;

public class Main {

    public static void main(String[] args) throws Exception {
        String filePath = "F://my-json.txt";
        BufferedReader reader = new BufferedReader(new FileReader(filePath));
        String temp = null;
        StringBuffer sbuffer = new StringBuffer();
        while ((temp = reader.readLine()) != null) {
            sbuffer.append(temp);
        }

        String jsonContent = sbuffer.toString();
        System.out.println(jsonContent);
        MyJson myJson = JSON.parseObject(jsonContent, MyJson.class);
        System.out.println(JSON.toJSONString(myJson));
        reader.close();
    }
}

class Children {

    private double amount;
    private int node;
    private String area;
    private String debtorName;
    private String accountId;
    private String debtorId;
    private String creditorId;
    private String creditorName;
    private List<Children> children;

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public int getNode() {
        return node;
    }

    public void setNode(int node) {
        this.node = node;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getDebtorName() {
        return debtorName;
    }

    public void setDebtorName(String debtorName) {
        this.debtorName = debtorName;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getDebtorId() {
        return debtorId;
    }

    public void setDebtorId(String debtorId) {
        this.debtorId = debtorId;
    }

    public String getCreditorId() {
        return creditorId;
    }

    public void setCreditorId(String creditorId) {
        this.creditorId = creditorId;
    }

    public String getCreditorName() {
        return creditorName;
    }

    public void setCreditorName(String creditorName) {
        this.creditorName = creditorName;
    }

    public List<Children> getChildren() {
        return children;
    }

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

class Chian {

    private double amount;
    private int node;
    private String area;
    private String debtorName;
    private String accountId;
    private String debtorId;
    private String creditorId;
    private List<Children> children;
    private String creditorName;

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public int getNode() {
        return node;
    }

    public void setNode(int node) {
        this.node = node;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getDebtorName() {
        return debtorName;
    }

    public void setDebtorName(String debtorName) {
        this.debtorName = debtorName;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getDebtorId() {
        return debtorId;
    }

    public void setDebtorId(String debtorId) {
        this.debtorId = debtorId;
    }

    public String getCreditorId() {
        return creditorId;
    }

    public void setCreditorId(String creditorId) {
        this.creditorId = creditorId;
    }

    public List<Children> getChildren() {
        return children;
    }

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

    public String getCreditorName() {
        return creditorName;
    }

    public void setCreditorName(String creditorName) {
        this.creditorName = creditorName;
    }
}

class Data {

    private String financeAmount;
    private double payAmount;
    private String area;
    private String userId;
    private int chainCount;
    private int seq;
    private String userName;
    private double receiveAmount;
    private List<Chian> chian;
    private double rongziAll;

    public String getFinanceAmount() {
        return financeAmount;
    }

    public void setFinanceAmount(String financeAmount) {
        this.financeAmount = financeAmount;
    }

    public double getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(double payAmount) {
        this.payAmount = payAmount;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public int getChainCount() {
        return chainCount;
    }

    public void setChainCount(int chainCount) {
        this.chainCount = chainCount;
    }

    public int getSeq() {
        return seq;
    }

    public void setSeq(int seq) {
        this.seq = seq;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public double getReceiveAmount() {
        return receiveAmount;
    }

    public void setReceiveAmount(double receiveAmount) {
        this.receiveAmount = receiveAmount;
    }

    public List<Chian> getChian() {
        return chian;
    }

    public void setChian(List<Chian> chian) {
        this.chian = chian;
    }

    public double getRongziAll() {
        return rongziAll;
    }

    public void setRongziAll(double rongziAll) {
        this.rongziAll = rongziAll;
    }
}

class MyJson {

    private List<Data> datas;
    private String result;
    private int count;
    private String page;
    private String msg;

    public List<Data> getDatas() {
        return datas;
    }

    public void setDatas(List<Data> datas) {
        this.datas = datas;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}

只引用了fastjson

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.49</version>
 </dependency>
wushucheng18
诚哥丿 我丢, 怎么是安卓,没注意啊
大约一年之前 回复

直接使用Android studio的GsonFormat可以自动生成
public class demo {

/**
 * datas : [{"payAmount":0,"area":"滁州市","userId":"3638b61f7ef74d95ad6c14d8bc0644ff","chainCount":3,"seq":1,"userName":"还是收到","receiveAmount":7,"chian":[{"amount":7,"node":1,"area":"","debtorName":"还是","accountId":"AC20180810000616","debtorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","creditorId":"3638b61f7ef74d95ad6c14d8bc0644ff","children":[{"amount":6,"node":2,"area":"","debtorName":"士大夫","accountId":"AC20180907000652","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"},{"amount":2,"node":2,"area":"","debtorName":"海阔天空","accountId":"AC20180912000657","debtorId":"a41dac80eaf940d58bcda3fe42faaaa3","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[{"amount":4,"node":3,"area":"","debtorName":"士大夫","accountId":"AC20180907000651","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"a41dac80eaf940d58bcda3fe42faaaa3","children":[],"creditorName":"海阔天空"}],"creditorName":"还是"},{"amount":9.0E7,"node":2,"area":"","debtorName":"士大夫","accountId":"AC20180824000639","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"}],"creditorName":"还是收到"}],"rongziAll":9.0000008E7},{"financeAmount":0,"payAmount":0,"area":"抚顺市","userId":"3a33493363594bdfaa304586ab62668c","chainCount":0,"seq":2,"userName":"A","receiveAmount":0,"chian":"","rongziAll":0},{"payAmount":0,"area":"佳木斯市","userId":"c92fce2d51154fc597421c0c2d4f9171","chainCount":1,"seq":3,"userName":"阿甘船运有限公司","receiveAmount":1500000,"chian":[{"amount":1500000,"node":1,"area":"","debtorName":"澳洲太和矿业有限公司","accountId":"AC20180412000452","debtorId":"1acc2644a97541e5a9291120e379f416","creditorId":"c92fce2d51154fc597421c0c2d4f9171","children":[],"creditorName":"阿甘船运有限公司"}],"rongziAll":1500000},{"financeAmount":0,"payAmount":0,"area":"南昌市","userId":"1260d446161c4d7c8220e5addccc30ed","chainCount":0,"seq":4,"userName":"个人附件阿萨德","receiveAmount":0,"chian":"","rongziAll":0},{"financeAmount":0,"payAmount":0,"area":"伊犁哈萨克自治州","userId":"3fdc805022814024872428a5cefc9793","chainCount":0,"seq":5,"userName":"贺声耀","receiveAmount":0,"chian":"","rongziAll":0},{"payAmount":7,"area":"滁州市","userId":"43ded7a2d9b647d3bd1d8a5f7125dab4","chainCount":3,"seq":6,"userName":"还是","receiveAmount":9.0000008E7,"chian":[{"amount":6,"node":1,"area":"","debtorName":"士大夫","accountId":"AC20180907000652","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"},{"amount":2,"node":1,"area":"","debtorName":"海阔天空","accountId":"AC20180912000657","debtorId":"a41dac80eaf940d58bcda3fe42faaaa3","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[{"amount":4,"node":2,"area":"","debtorName":"士大夫","accountId":"AC20180907000651","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"a41dac80eaf940d58bcda3fe42faaaa3","children":[],"creditorName":"海阔天空"}],"creditorName":"还是"},{"amount":9.0E7,"node":1,"area":"","debtorName":"士大夫","accountId":"AC20180824000639","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"}],"rongziAll":9.0000008E7},{"financeAmount":0,"payAmount":1500000,"area":"长春市","userId":"1acc2644a97541e5a9291120e379f416","chainCount":0,"seq":7,"userName":"澳洲太和矿业有限公司","receiveAmount":0,"chian":"","rongziAll":0},{"financeAmount":0,"payAmount":0,"area":"怀化市","userId":"7869179be7b74951994de20448970fe3","chainCount":0,"seq":8,"userName":"Shhshs","receiveAmount":0,"chian":"","rongziAll":0},{"payAmount":2,"area":"贵阳市","userId":"a41dac80eaf940d58bcda3fe42faaaa3","chainCount":1,"seq":9,"userName":"海阔天空","receiveAmount":4,"chian":[{"amount":4,"node":1,"area":"","debtorName":"士大夫","accountId":"AC20180907000651","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"a41dac80eaf940d58bcda3fe42faaaa3","children":[],"creditorName":"海阔天空"}],"rongziAll":4},{"financeAmount":0,"payAmount":9.000001E7,"area":"澳门","userId":"265581f4b83540a09cd8fba8797e7065","chainCount":0,"seq":10,"userName":"士大夫","receiveAmount":0,"chian":"","rongziAll":0}]
 * result : success
 * count : 10
 * page : 1
 * msg : 0
 */

private String result;
private int count;
private String page;
private String msg;
private List<DatasBean> datas;

public String getResult() {
    return result;
}

public void setResult(String result) {
    this.result = result;
}

public int getCount() {
    return count;
}

public void setCount(int count) {
    this.count = count;
}

public String getPage() {
    return page;
}

public void setPage(String page) {
    this.page = page;
}

public String getMsg() {
    return msg;
}

public void setMsg(String msg) {
    this.msg = msg;
}

public List<DatasBean> getDatas() {
    return datas;
}

public void setDatas(List<DatasBean> datas) {
    this.datas = datas;
}

public static class DatasBean {
    /**
     * payAmount : 0
     * area : 滁州市
     * userId : 3638b61f7ef74d95ad6c14d8bc0644ff
     * chainCount : 3
     * seq : 1
     * userName : 还是收到
     * receiveAmount : 7.0
     * chian : [{"amount":7,"node":1,"area":"","debtorName":"还是","accountId":"AC20180810000616","debtorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","creditorId":"3638b61f7ef74d95ad6c14d8bc0644ff","children":[{"amount":6,"node":2,"area":"","debtorName":"士大夫","accountId":"AC20180907000652","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"},{"amount":2,"node":2,"area":"","debtorName":"海阔天空","accountId":"AC20180912000657","debtorId":"a41dac80eaf940d58bcda3fe42faaaa3","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[{"amount":4,"node":3,"area":"","debtorName":"士大夫","accountId":"AC20180907000651","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"a41dac80eaf940d58bcda3fe42faaaa3","children":[],"creditorName":"海阔天空"}],"creditorName":"还是"},{"amount":9.0E7,"node":2,"area":"","debtorName":"士大夫","accountId":"AC20180824000639","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"}],"creditorName":"还是收到"}]
     * rongziAll : 9.0000008E7
     * financeAmount : 0
     */

    private int payAmount;
    private String area;
    private String userId;
    private int chainCount;
    private int seq;
    private String userName;
    private double receiveAmount;
    private double rongziAll;
    private int financeAmount;
    private List<ChianBean> chian;

    public int getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(int payAmount) {
        this.payAmount = payAmount;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public int getChainCount() {
        return chainCount;
    }

    public void setChainCount(int chainCount) {
        this.chainCount = chainCount;
    }

    public int getSeq() {
        return seq;
    }

    public void setSeq(int seq) {
        this.seq = seq;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public double getReceiveAmount() {
        return receiveAmount;
    }

    public void setReceiveAmount(double receiveAmount) {
        this.receiveAmount = receiveAmount;
    }

    public double getRongziAll() {
        return rongziAll;
    }

    public void setRongziAll(double rongziAll) {
        this.rongziAll = rongziAll;
    }

    public int getFinanceAmount() {
        return financeAmount;
    }

    public void setFinanceAmount(int financeAmount) {
        this.financeAmount = financeAmount;
    }

    public List<ChianBean> getChian() {
        return chian;
    }

    public void setChian(List<ChianBean> chian) {
        this.chian = chian;
    }

    public static class ChianBean {
        /**
         * amount : 7.0
         * node : 1
         * area : 
         * debtorName : 还是
         * accountId : AC20180810000616
         * debtorId : 43ded7a2d9b647d3bd1d8a5f7125dab4
         * creditorId : 3638b61f7ef74d95ad6c14d8bc0644ff
         * children : [{"amount":6,"node":2,"area":"","debtorName":"士大夫","accountId":"AC20180907000652","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"},{"amount":2,"node":2,"area":"","debtorName":"海阔天空","accountId":"AC20180912000657","debtorId":"a41dac80eaf940d58bcda3fe42faaaa3","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[{"amount":4,"node":3,"area":"","debtorName":"士大夫","accountId":"AC20180907000651","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"a41dac80eaf940d58bcda3fe42faaaa3","children":[],"creditorName":"海阔天空"}],"creditorName":"还是"},{"amount":9.0E7,"node":2,"area":"","debtorName":"士大夫","accountId":"AC20180824000639","debtorId":"265581f4b83540a09cd8fba8797e7065","creditorId":"43ded7a2d9b647d3bd1d8a5f7125dab4","children":[],"creditorName":"还是"}]
         * creditorName : 还是收到
         */

        private double amount;
        private int node;
        private String area;
        private String debtorName;
        private String accountId;
        private String debtorId;
        private String creditorId;
        private String creditorName;
        private List<ChildrenBean> children;

        public double getAmount() {
            return amount;
        }

        public void setAmount(double amount) {
            this.amount = amount;
        }

        public int getNode() {
            return node;
        }

        public void setNode(int node) {
            this.node = node;
        }

        public String getArea() {
            return area;
        }

        public void setArea(String area) {
            this.area = area;
        }

        public String getDebtorName() {
            return debtorName;
        }

        public void setDebtorName(String debtorName) {
            this.debtorName = debtorName;
        }

        public String getAccountId() {
            return accountId;
        }

        public void setAccountId(String accountId) {
            this.accountId = accountId;
        }

        public String getDebtorId() {
            return debtorId;
        }

        public void setDebtorId(String debtorId) {
            this.debtorId = debtorId;
        }

        public String getCreditorId() {
            return creditorId;
        }

        public void setCreditorId(String creditorId) {
            this.creditorId = creditorId;
        }

        public String getCreditorName() {
            return creditorName;
        }

        public void setCreditorName(String creditorName) {
            this.creditorName = creditorName;
        }

        public List<ChildrenBean> getChildren() {
            return children;
        }

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

        public static class ChildrenBean {
            /**
             * amount : 6.0
             * node : 2
             * area : 
             * debtorName : 士大夫
             * accountId : AC20180907000652
             * debtorId : 265581f4b83540a09cd8fba8797e7065
             * creditorId : 43ded7a2d9b647d3bd1d8a5f7125dab4
             * children : []
             * creditorName : 还是
             */

            private double amount;
            private int node;
            private String area;
            private String debtorName;
            private String accountId;
            private String debtorId;
            private String creditorId;
            private String creditorName;
            private List<?> children;

            public double getAmount() {
                return amount;
            }

            public void setAmount(double amount) {
                this.amount = amount;
            }

            public int getNode() {
                return node;
            }

            public void setNode(int node) {
                this.node = node;
            }

            public String getArea() {
                return area;
            }

            public void setArea(String area) {
                this.area = area;
            }

            public String getDebtorName() {
                return debtorName;
            }

            public void setDebtorName(String debtorName) {
                this.debtorName = debtorName;
            }

            public String getAccountId() {
                return accountId;
            }

            public void setAccountId(String accountId) {
                this.accountId = accountId;
            }

            public String getDebtorId() {
                return debtorId;
            }

            public void setDebtorId(String debtorId) {
                this.debtorId = debtorId;
            }

            public String getCreditorId() {
                return creditorId;
            }

            public void setCreditorId(String creditorId) {
                this.creditorId = creditorId;
            }

            public String getCreditorName() {
                return creditorName;
            }

            public void setCreditorName(String creditorName) {
                this.creditorName = creditorName;
            }

            public List<?> getChildren() {
                return children;
            }

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

}

嵌套for循环手动JSON来解析就行.类似递归

因为数据不确定,同一个字段对应的可能是JSONObject也可能是JSONArray,所以不好写java bean。只能手动递归解析,判断是object还是array循环解析

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
如何解析嵌套Json字符串,不使用第三方JAR
-
json解析格式问题。。。。。
-
JAVA 集合转JSON 嵌套循环
-
怎么递归json嵌套json?
-
Java解析嵌套json数据,嵌套结构怎么弄?
-
IOS5嵌套的json解析问题
-
多重循环是从里面到外读还是从外往里读,,,,,,,,循环嵌套
-
谁可以帮我解释下这个循环的嵌套么?最好来几个简单例题
-
函数和循环的类别是什么?为什么函数不能像循环那样嵌套调用呢?
-
java跳出嵌套循环的处理方法
-
关于json嵌套解析
-
Java Gson解析多层嵌套json字符串
-
如何在json格式里 嵌套一个json格式的数据
-
怎么判断是不是for循环嵌套
-
Action获取嵌套的json数据
-
未能解析类中的嵌套类型咋回事?
-
【python】JSON嵌套字典循环替换值,并且作判断
-
c++如何实现用函数递归进行多重循环嵌套
-
数据库读取出来的数据如何组装多层嵌套的json
-
程序员竟然钟爱这个!我 low了
今天和一帮程序员大佬群里闲聊(需要入群的可以加最底下微信哦~)聊着聊着竟然扯到鞋子一直在讨论穿什么鞋子比较耐脏然后一帮大佬集中围殴小白鞋说小白鞋虽然百搭但是太容易脏,太不...
程序员实用工具网站
目录 1、搜索引擎 2、PPT 3、图片操作 4、文件共享 5、应届生招聘 6、程序员面试题库 7、办公、开发软件 8、高清图片、视频素材网站 9、项目开源 10、算法 11、在线工具宝典大全 程序员开发需要具备良好的信息检索能力,为了备忘(收藏夹真是满了),将开发过程中常用的网站进行整理。 1、搜索引擎 1.1、秘迹搜索 一款无敌有良心、无敌安全的搜索引擎,不会收...
996下的程序员,该如何保证自己的身体健康?
作者:陈大鱼头github:KRISACHAN自从开始写代码之后,一天里大部分的时间都贡献了给了电脑跟那张从X总办公室里搬回来的人体工学椅了。鱼头也经历过无数次的 肥胖 ...
史上最详细的IDEA优雅整合Maven+SSM框架(详细思路+附带源码)
网上很多整合SSM博客文章并不能让初探ssm的同学思路完全的清晰,可以试着关掉整合教程,摇两下头骨,哈一大口气,就在万事具备的时候,开整,这个时候你可能思路全无 ~中招了咩~ ,还有一些同学依旧在使用eclipse或者Myeclipse开发,我想对这些朋友说IDEA 的编译速度很快,人生苦短,来不及解释了,直接上手idea吧。这篇文章每一步搭建过程都测试过了,应该不会有什么差错。本文章还有个比较优秀的特点,就是idea的使用,基本上关于idea的操作都算是比较详细的,所以不用太担心不会撸idea!最后,本文
全球最厉害的 14 位程序员!
来源 | ITWorld 整理自网络全球最厉害的 14 位程序员是谁?今天就让我们一起来了解一下吧,排名不分先后。01. Jon Skeet个人名望:程序技术问答网站 S...
我花了一夜用数据结构给女朋友写个H5走迷宫游戏
起因 又到深夜了,我按照以往在csdn和公众号写着数据结构!这占用了我大量的时间!我的超越妹妹严重缺乏陪伴而 怨气满满! 而女朋友时常埋怨,认为数据结构这么抽象难懂的东西没啥作用,常会问道:天天写这玩意,有啥作用。而我答道:能干事情多了,比如写个迷宫小游戏啥的! 当我码完字准备睡觉时:写不好别睡觉! 分析 如果用数据结构与算法造出东西来呢? ...
招人!入职阿里仅1年,我和做AI的程序员薪资翻了2倍!
最近在知乎上,关于AI的这个话题又被顶起来,其中,这条回答让人印象深刻:在这短短的一条信息里,无疑显示出:AI行业缺人,高端岗位80万年薪恐怕也招不来!小编上周在一个AI...
什么是大公司病(太形象了)
点击蓝色“五分钟学算法”关注我哟加个“星标”,天天中午 12:15,一起学算法作者 | 南之鱼来源 | 芝麻观点(chinamkt)所谓大企业病,一般都具有机构臃肿、多重...
让程序员崩溃的瞬间(非程序员勿入)
今天给大家带来点快乐,程序员才能看懂。 来源:https://zhuanlan.zhihu.com/p/47066521 1. 公司实习生找 Bug 2.在调试时,将断点设置在错误的位置 3.当我有一个很棒的调试想法时 4.偶然间看到自己多年前写的代码 5.当我第一次启动我的单元测试时 ...
Spring高级技术梳理
Spring高级技术梳理 序言正文SpringDate部分Spring全家桶之SpringData——预科阶段Spring全家桶之SpringData——Spring 整合Hibernate与Hibernate JpaSpring全家桶之SpringData——Spring Data JPASpring全家桶之SpringData——SpringData RedisSpringBoot部分Sp...
Git 天天用 但是 Git 原理你了解吗?
Git 原理 做技术一定要知其然知其所以然,意思就是:知道它是这样的,更知道它为什么是这样的。我主要通过4块内容来简单介绍 Git 是原理是什么样的。这4块内容如下: Git 存储目录结构介绍 Git 是如何存储的 Git 的对象 Git引用 当然 Git 原理不仅仅包含这些,想要更深入了解请查看官方教程 https://git-scm.com/book/zh/v2/。 本文内容是我在 Git...
Android——微信自动回复实现
首先本文的测试微信版本是7.0.3 ,亲测可以使用。 需要实现-抓取微信自动回复消息的功能点。 一.首先打开DDMS,使用按钮。 在微信中回复一个消息 点击Stop Method Profiling。 二.查看生成的报表,观察到如下两个方法 其中1应该是发送消息的接口方法。2应该是UI层显示的方法。 三.首先分析第一个方法: 1.,可以看到,参数值是String,返...
分享靠写代码赚钱的一些门路
作者 mezod,译者 josephchang10如今,通过自己的代码去赚钱变得越来越简单,不过对很多人来说依然还是很难,因为他们不知道有哪些门路。今天给大家分享一个精彩...
对计算机专业来说学历真的重要吗?
我本科学校是渣渣二本,研究生学校是985,现在毕业五年,校招笔试、面试,社招面试参加了两年了,就我个人的经历来说下这个问题。 这篇文章很长,但绝对是精华,相信我,读完以后,你会知道学历不好的解决方案,记得帮我点赞哦。 先说结论,无论赞不赞同,它本质就是这样:对于技术类工作而言,学历五年以内非常重要,但有办法弥补。五年以后,不重要。 目录: 张雪峰讲述的事实 我看到的事实 为什么会这样 ...
技术人员要拿百万年薪,必须要经历这9个段位
很多人都问,技术人员如何成长,每个阶段又是怎样的,如何才能走出当前的迷茫,实现自我的突破。所以我结合我自己10多年的从业经验,总结了技术人员成长的9个段位,希望对大家的职...
8000字干货:那些很厉害的人是怎么构建知识体系的
本文约8000字,正常阅读需要15~20分钟。读完本文可以获得如下收益: 分辨知识和知识体系的差别 理解如何用八大问发现知识的连接点; 掌握致用类知识体系的构建方法; 能够应用甜蜜区模型找到特定领域来构建知识体系。 1. 知识体系?有必要吗? 小张准备通过跑步锻炼身体,可因为之前听说过小腿变粗、膝盖受伤、猝死等等与跑步有关的意外状况,有点担心自己会掉进各种坑里,就在微信上问朋友圈一直晒跑步...
万字长文!线性代数的本质课程笔记完整合集
点击上方“Datawhale”,选择“星标”公众号第一时间获取价值内容系列目录1.向量究竟是什么https://www.bilibili.com/video/av5987...
Java 网络爬虫,就是这么的简单
这是 Java 网络爬虫系列文章的第一篇,如果你还不知道 Java 网络爬虫系列文章,请参看 学 Java 网络爬虫,需要哪些基础知识。第一篇是关于 Java 网络爬虫入门内容,在该篇中我们以采集虎扑列表新闻的新闻标题和详情页为例,需要提取的内容如下图所示: 我们需要提取图中圈出来的文字及其对应的链接,在提取的过程中,我们会使用两种方式来提取,一种是 Jsoup 的方式,另一种是 httpcli...
nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件
文章目录前言一、nginx简介1. 什么是 nginx 和可以做什么事情2.Nginx 作为 web 服务器3. 正向代理4. 反向代理5. 动静分离6.动静分离二、Nginx 的安装三、 Nginx 的常用命令和配置文件四、 Nginx 配置实例 1 反向代理五、 Nginx 配置实例 2 负载均衡六、 Nginx 配置实例 3 动静分离七、 Nginx 的高可用集群 前言 一、nginx简介...
Java 爬虫遇上数据异步加载,试试这两种办法!
这是 Java 爬虫系列博文的第三篇,在上一篇 Java 爬虫遇到需要登录的网站,该怎么办? 中,我们简单的讲解了爬虫时遇到登录问题的解决办法,在这篇文章中我们一起来聊一聊爬虫时遇到数据异步加载的问题,这也是爬虫中常见的问题。 现在很多都是前后端分离项目,这会使得数据异步加载问题更加突出,所以你在爬虫时遇到这类问题不必惊讶,不必慌张。对于这类问题的解决办法总体来说有以下两种: 1、内置一个浏览器内...
Angular 入门教程系列:39:使用ng-alain进行开发
在前面的文章中介绍过ng-alain,当时在使用的时候还显得不是很方便,最简单的一个demo运行的都不是非常流畅。而目前的版本已经做有较大的改进,再这个基础上进行二次开发,尤其是一些后端的平台或者监控的平台看起来都比较不错。在这篇文章中继续来确认一下使用的感受。
相关热词 c#该名称在封闭局部范围 c#泛型 排序 c# 测试连接mysql c# 多线程 调用界面值 c# gdi unity c#反射构造带参对象 一起自学c# c#工厂方法 c# 对象属性保存xml u3d用c#写拾取物品