I need to convert 2-D array comes from JSON to a string. I just need to manipulate that value.
There is an example of the JSON:
https://en.wikipedia.org/wiki/GeoJSON
@RequestMapping is the way to manipulate value that comes from REST. But i dont know how to do it for nested object.
@ResponseBody
public GeoJson saveData(@RequestParam {What i need}...) throws IOException{
return geoJSONRepository.save(geoJson);
}
GeoJson class:
@Entity
public class GeoJson {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String type;
@OneToMany(cascade = CascadeType.ALL)
@ToString.Exclude
private List<Feature> features = new ArrayList<Feature>();
public GeoJson() {
}
}
Feature class:
@Entity
public class Feature {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long fId;
private String type;
@OneToOne(cascade = CascadeType.ALL)
private Properties properties;
@OneToOne(cascade = CascadeType.ALL)
private Geometry geometry;
}
Properties class:
@Entity
public class Properties {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "pId", nullable = false)
private Long pId;
@Column(name = "property_type")
private String type;
}
Geometry class:
@Entity
public class Geometry {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "gId", nullable = false)
private Long gId;
private String type;
private String coordinates; //2-d coordinates value
}