gpt4 book ai didi

java - org.springframework.dao.InvalidDataAccessApiUsageException : The given string value: [] cannot be transformed to Json object

转载 作者:行者123 更新时间:2023-12-01 17:42:29 28 4
gpt4 key购买 nike

我遇到这样的错误。

nested exception is java.lang.IllegalArgumentException: The given string value: [{"id": "DFW", "namd": "Dallas, TX (DFW-Dallas-Fort Worth Intl.)", "name_kr": "댈러스, 텍사스 (DFW-댈러스-포트워스 국제공항)"}, {"id": "DAL", "namd": "Dallas, TX (DAL-Love Field)", "name_kr": "댈라스, 텍사스 (DAL-러브필드 공항)"}, {"id": "RBD", "namd": "Dallas, TX (RBD-Executive)", "name_kr": "댈러스, 텍사스 (RBD-이그제큐티브)"}, {"id": "ADS", "namd": "Dallas, TX (ADS-Addison)", "name_kr": "댈러스, 텍사스 (ADS-애디슨 공항)"}] cannot be transformed to Json object

这个值是我的 postgres 行的 jsonb 列。

这是我的表实体示例(相关问题)。


@Data
@Entity
@Table(name = "expedia_region_union")
@JsonInclude(JsonInclude.Include.NON_NULL)
@TypeDefs({
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
public class ExpediaRegionUnion {


@Id
// @GeneratedValue
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column( columnDefinition = "uuid", updatable = false )
private String regionId;


@Type(type = "jsonb")
@Column(columnDefinition = "airport")
private HashMap airport;



@Column(name = "source_time")
private String sourceTime;

在我看来,实体 map 似乎无法处理机场领域。airport 字段以 jsonb 类型列出。但我制作了像 HashMap 这样的实体规则。

样本数据

about airport field

[
{
"id": "DFW",
"namd": "Dallas, TX (DFW-Dallas-Fort Worth Intl.)",
"name_kr": "댈러스, 텍사스 (DFW-댈러스-포트워스 국제공항)"
},
{
"id": "DAL",
"namd": "Dallas, TX (DAL-Love Field)",
"name_kr": "댈라스, 텍사스 (DAL-러브필드 공항)"
},
{
"id": "RBD",
"namd": "Dallas, TX (RBD-Executive)",
"name_kr": "댈러스, 텍사스 (RBD-이그제큐티브)"
},
{
"id": "ADS",
"namd": "Dallas, TX (ADS-Addison)",
"name_kr": "댈러스, 텍사스 (ADS-애디슨 공항)"
}
]

enter image description here

如何更改实体设置?

最佳答案

您的示例数据与您的期望不符。

"airport" : "[{\"id\": \"DFW\", \"namd\": \"Dallas, TX (DFW-Dallas-Fort Worth Intl.)\", \"name_kr\": \"댈러스, 텍사스 (DFW-댈러스-포트워스 국제공항)\"}, ...]"

不是数组,而是字符串,由值周围的引号显示。有效的 JSON 数组如下所示

"airport" : [{"id": "DFW", "namd": "Dallas, TX (DFW-Dallas-Fort Worth Intl.)", "name_kr": "댈러스, 텍사스 (DFW-댈러스-포트워스 국제공항)"}, {"id": "DAL", "namd": "Dallas, TX (DAL-Love Field)", "name_kr": "댈라스, 텍사스 (DAL-러브필드 공항)"}, {"id": "RBD", "namd": "Dallas, TX (RBD-Executive)", "name_kr": "댈러스, 텍사스 (RBD-이그제큐티브)"}, {"id": "ADS", "namd": "Dallas, TX (ADS-Addison)", "name_kr": "댈러스, 텍사스 (ADS-애디슨 공항)"}]

关于java - org.springframework.dao.InvalidDataAccessApiUsageException : The given string value: [] cannot be transformed to Json object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60928132/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com