【问题标题】:POST a request with NO JSON inside a JSON in SpringBoot在 Spring Boot 中的 JSON 中发布没有 JSON 的请求
【发布时间】:2020-09-08 08:28:10
【问题描述】:

我正在使用带有 JPA 的 spring-boot。我想摆脱多余的 JSON。正确的做法是什么?

拥有(默认):

{
    "latitude":20.0,
    "longitude":20.0,
    "picturesURLs": [
        "google.com",
        "unaimagen.com"
        ],
    "animal":{
        "id": 1
    },
    "usuario": {
        "id": 1
    },
    "longitudAnimal": "123.345"
}

想要:

{
    "latitude":20.0,
    "longitude":20.0,
    "picturesURLs": [
        "google.com",
        "unaimagen.com"
        ],
    "animal": 1,
    "usuario": 1,
    "longitudAnimal": "123.345"
}

【问题讨论】:

标签: json spring spring-boot spring-data-jpa


【解决方案1】:

您需要使用 DTO(数据传输对象)。 Check this link

【讨论】:

    猜你喜欢
    • 2014-05-17
    • 2020-04-30
    • 1970-01-01
    • 2021-06-10
    • 2023-04-05
    • 2019-03-18
    • 1970-01-01
    • 1970-01-01
    • 2021-10-07
    相关资源
    最近更新 更多