gpt4 book ai didi

java - 我需要定义什么类型的变量来插入以下类型的数据(Spring-boot,Mongodb)

转载 作者:行者123 更新时间:2023-12-02 09:26:56 24 4
gpt4 key购买 nike

数据类型:

"label":"Price","type":"RANGE_SELECT","value":{"min":1,"max":100,"default":50} 

"label":"Wi-Fi","type":"SWITCH","value":"true"

"label":"Start Date","type":"DATE_PICKER","value":""

我描述的变量类型如下:

private String label;
private String type;
private List < String > value;

错误:

"message": "JSON parse error: Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: (PushbackInputStream); line: 4, column: 10] (through reference chain: com.mspace.uiservice.model.UiFilter[\"value\"])",

最佳答案

您需要创建一个这样的类

class Value {
private Integer min;
private Integer max;
private Integer default;

//Getters, Setters
}

并像这样改变你的pojo

private String label;
private String type;
private Value value;

如果是[....],则可以使用List,但不能用于{...}

关于java - 我需要定义什么类型的变量来插入以下类型的数据(Spring-boot,Mongodb),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58281668/

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