下面是模拟数据 要用"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"
}
可以用递归,也可以不用。递归简单,就不说了。
不用递归伪代码如下:
当前层次 = 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>
直接使用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循环解析