想将数据保存为这样子:
[{ "subject": { "code": "B123", "words": [{ "key": "gjc1", "wight": 9.8, "ct": 1575126920 }, { "key": "gjc1", "wight": 9.8, "ct": 1575126920 }, { "key": "gjc1", "wight": 9.8, "ct": 1575126920 }], "wight": 3, "ct": 1575126920 } }, { "subject": { "code": "C456", "words": [{ "key": "gjc1", "wight": 9.8, "ct": 1575126920 }, { "key": "gjc1", "wight": 9.8, "ct": 1575126920 }, { "key": "gjc1", "wight": 9.8, "ct": 1575126920 }], "wight": 3, "ct": 1575126920 } } ]
转换为Java后,如:
/** * Copyright 2019 bejson.com */ package com.besjon.pojo; /** * Auto-generated: 2019-11-30 23:24:14 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ public class JsonRootBean { private Subject subject; public void setSubject(Subject subject) { this.subject = subject; } public Subject getSubject() { return subject; } }
/** * Copyright 2019 bejson.com */ package com.besjon.pojo; import java.util.List; /** * Auto-generated: 2019-11-30 23:24:14 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ public class Subject { private String code; private List<Words> words; private int wight; private long ct; public void setCode(String code) { this.code = code; } public String getCode() { return code; } public void setWords(List<Words> words) { this.words = words; } public List<Words> getWords() { return words; } public void setWight(int wight) { this.wight = wight; } public int getWight() { return wight; } public void setCt(long ct) { this.ct = ct; } public long getCt() { return ct; } }
/** * Copyright 2019 bejson.com */ package com.besjon.pojo; /** * Auto-generated: 2019-11-30 23:24:14 * * @author bejson.com (i@bejson.com) * @website http://www.bejson.com/java2pojo/ */ public class Words { private String key; private double wight; private long ct; public void setKey(String key) { this.key = key; } public String getKey() { return key; } public void setWight(double wight) { this.wight = wight; } public double getWight() { return wight; } public void setCt(long ct) { this.ct = ct; } public long getCt() { return ct; } }
直此,完成!!!