如何使用Spring Boot通过Postman操纵数据。

huangapple go评论86阅读模式
英文:

How to manipulate data through postman with spring boot

问题

以下是在Postman中的请求负载:

{
   "name":"xyz",
   "username":"xyz@123",
   "address":{
      "street":{
         "locations":[
            {
               "lng":-12.2342,
               "lat":23.1234
            },
            {
               "lng":-12.2342,
               "lat":23.1234
            },
            {
               "lng":-12.2342,
               "lat":23.1234
            }
         ]
      }
   }
}

我有一个数据库模式如下:

id(pk) string
name string
username string
geometry string

在上述模式中,geometry字段包含以字符串格式的lng/lat数组,例如 polygon(-12.2342 23.1234,-12.2342 23.1234,-12.2342 23.1234)。那么,我该如何将上述请求负载中的lat/lng数组转换为字符串类型,以便我可以在Spring Boot中将其存储在MySQL数据库中,数据类似于 polygon(-12.2342 23.1234,-12.2342 23.1234,-12.2342 23.1234)

英文:

Following are request payload in postman:

{
"name":"xyz",
"usename":"xyz@123",
"address":{
  "street":{
  "locations":[{
     "lng":-12.2342,
     "lat":23.1234
  },
   {
    "lng":-12.2342,
    "lat":23.1234
   },
   {
    "lng":-12.2342,
    "lat":23.1234
    }]
  }
 }
}

and i have database schema like

id(pk)string
name String
username String
geometry String

in above schema geometry field contains array of lng/lat in string format

like polygon(-12.2342 23.1234,-12.2342 23.1234,-12.2342 23.1234)

so how can i convert above request payload array of lat/lng to string type so that i can store it in mysql database like data polygon(-12.2342 23.1234,-12.2342 23.1234,-12.2342 23.1234) with springboot?

答案1

得分: 0

  1. 将负载中的呼叫位置称为 locations,因为它是一个数组:

  2. 有如下实体:

    class Location{
    
       double long;
       double lat;
    
    }
    
    class Street {
      List<Location> locations; 
    }
    
    class Address {
       Street street; 
    }
    
    class RequestData {
      String name;
    
      String userName;
    
     Address address;
    }
英文:
  1. Call location in payload as locations because its array:

  2. Have entities like below:

    class Location{
    
       double long;
       double lat;
    
    }
    
    class Street {
      List<Location> locations; 
    }
    
    class Address {
       Street street; 
    }
    
    class RequestData {
      String name;
    
      String userName;
    
     Address address;
    }

huangapple
  • 本文由 发表于 2020年1月3日 15:25:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/59574688.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定