The task is to parse the data with api in the form of json and write to postgresql in the database.

json looks like this:

[{ DepId=123, PoName=Название, PoType=Тип, Mestnost1=Городская, Mestnost2=Стационарное, PoStatus=1, PostIndex=010000 }] 

You can throw off any examples, everything seems to be searched or not correctly fumbled.

  • 3
    But this is not JSON. - Nofate
  • For JSON in Spring, see Jackson (in Spring Boot it is out of the box). But in your example, the format is more similar to the work of the toString () method on the list of objects, and not JSON. - Nofate
  • Oh, sorry, yes, this is not json. I through restTemplate wrote it already in List. Then I am at a dead end, how can I get out, for example, DepId and PoName? - Yerassyl Toktagazin
  • Add the code that you got. - MrFylypenko Sep.

1 answer 1

Create a class

 public class DepartmentDto { @JsonProperty("DepId") private Integer depId; @JsonProperty("PoName") private String poName; @JsonProperty("PoType") private String poType; @JsonProperty("Mestnost1") private String mestnost1; @JsonProperty("Mestnost2") private String mestnost2; @JsonProperty("PoStatus") private Integer poStatus; @JsonProperty("PostIndex") private String postIndex; // геттеры, сеттеры } 

Receive through restTemplate collections of instances of this class and do with it what you want (for example, move the Entity class to JPA and write to the database).