create java pojo from json
Підписуйтеся на Telegram-канал «DOU #tech», щоб не пропустити нові технічні статті
всім привіт
є такий джсон
{ "table":[ { "row":[ {"value":"125","color":[125,125,13]}, {"value":"12","color":[12,12,12]}, {"value":"125","color":[25,15,13]} ] },{ "row":[ {"value":"125","color":[25,15,23]}, {"value":"125","color":[25,5,1]}, {"value":"125","color":[25,125,123]} ] } ] }
мені треба по ньому зробити джава класи
@JsonPropertyOrder public class Row { @JsonProperty List<JsonCell> cells; @JsonProperty public List<JsonCell> getCells() { return cells; } public void setCells(List<JsonCell> cells) { this.cells = cells; } }
@JsonPropertyOrder public class JsonCell { private String value; private List<Integer> color = new ArrayList<>(); @JsonProperty("value") public String getValue(){ return this.value; } public void setValue(String value){ this.value = value; } @JsonProperty("color") public List<Integer> getColor(){ return this.color; } }
В мене проблеми з класом Row. Field ’value’ воно шукає не в JsonCell а в Row. І викидає таку помилку
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "value" (Class com.compas.dashboards.xlsx.pojo.Row), not marked as ignorable at [Source: java.io.StringReader@40a8d1e4; line: 5, column: 27] (through reference chain: com.compas.dashboards.xlsx.pojo.RequestJsonDto["table"]->com.compas.dashboards.xlsx.pojo.Table["row"]->com.compas.dashboards.xlsx.pojo.Row["value"])
8 коментарів
Додати коментар Підписатись на коментаріВідписатись від коментарів