| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import com.fasterxml.jackson.databind.ObjectMapper;
- public class TestJacksonMapping {
- public static void main(String[] args) {
- try {
- String json = "{\"id\": 111, \"coordinates\": \"119.14413000000002,25.867905,-1.165372999387529\", \"rotationX\": 0, \"rotationY\": 0, \"rotationZ\": 260, \"scaleX\": 1, \"scaleY\": 1, \"scaleZ\": 1}";
-
- ObjectMapper mapper = new ObjectMapper();
- TestModel model = mapper.readValue(json, TestModel.class);
-
- System.out.println("=== 反序列化结果 ===");
- System.out.println("modelId: " + model.getModelId());
- System.out.println("modelCoordinates: " + model.getModelCoordinates());
- System.out.println("rotationX: " + model.getRotationX());
- System.out.println("rotationY: " + model.getRotationY());
- System.out.println("rotationZ: " + model.getRotationZ());
- System.out.println("scaleX: " + model.getScaleX());
- System.out.println("scaleY: " + model.getScaleY());
- System.out.println("scaleZ: " + model.getScaleZ());
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- static class TestModel {
- private Long modelId;
- private String modelCoordinates;
- private Double rotationX;
- private Double rotationY;
- private Double rotationZ;
- private Double scaleX;
- private Double scaleY;
- private Double scaleZ;
-
- public Long getModelId() {
- return modelId;
- }
-
- public void setId(Long id) {
- this.modelId = id;
- }
-
- public String getModelCoordinates() {
- return modelCoordinates;
- }
-
- public void setCoordinates(String coordinates) {
- this.modelCoordinates = coordinates;
- }
-
- public Double getRotationX() {
- return rotationX;
- }
-
- public void setRotationX(Double rotationX) {
- this.rotationX = rotationX;
- }
-
- public Double getRotationY() {
- return rotationY;
- }
-
- public void setRotationY(Double rotationY) {
- this.rotationY = rotationY;
- }
-
- public Double getRotationZ() {
- return rotationZ;
- }
-
- public void setRotationZ(Double rotationZ) {
- this.rotationZ = rotationZ;
- }
-
- public Double getScaleX() {
- return scaleX;
- }
-
- public void setScaleX(Double scaleX) {
- this.scaleX = scaleX;
- }
-
- public Double getScaleY() {
- return scaleY;
- }
-
- public void setScaleY(Double scaleY) {
- this.scaleY = scaleY;
- }
-
- public Double getScaleZ() {
- return scaleZ;
- }
-
- public void setScaleZ(Double scaleZ) {
- this.scaleZ = scaleZ;
- }
- }
- }
|