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

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

How to manipulate data through postman with spring boot

问题

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

  1. {
  2. "name":"xyz",
  3. "username":"xyz@123",
  4. "address":{
  5. "street":{
  6. "locations":[
  7. {
  8. "lng":-12.2342,
  9. "lat":23.1234
  10. },
  11. {
  12. "lng":-12.2342,
  13. "lat":23.1234
  14. },
  15. {
  16. "lng":-12.2342,
  17. "lat":23.1234
  18. }
  19. ]
  20. }
  21. }
  22. }

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

  1. id(pk) string
  2. name string
  3. username string
  4. 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:

  1. {
  2. "name":"xyz",
  3. "usename":"xyz@123",
  4. "address":{
  5. "street":{
  6. "locations":[{
  7. "lng":-12.2342,
  8. "lat":23.1234
  9. },
  10. {
  11. "lng":-12.2342,
  12. "lat":23.1234
  13. },
  14. {
  15. "lng":-12.2342,
  16. "lat":23.1234
  17. }]
  18. }
  19. }
  20. }

and i have database schema like

  1. id(pk)string
  2. name String
  3. username String
  4. 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. 有如下实体:

  1. class Location{
  2. double long;
  3. double lat;
  4. }
  5. class Street {
  6. List<Location> locations;
  7. }
  8. class Address {
  9. Street street;
  10. }
  11. class RequestData {
  12. String name;
  13. String userName;
  14. Address address;
  15. }
英文:
  1. Call location in payload as locations because its array:

  2. Have entities like below:

  1. class Location{
  2. double long;
  3. double lat;
  4. }
  5. class Street {
  6. List<Location> locations;
  7. }
  8. class Address {
  9. Street street;
  10. }
  11. class RequestData {
  12. String name;
  13. String userName;
  14. Address address;
  15. }

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:

确定