Tried to use Spring Boot to load the different DataType
PLAIN_TEXT_INPUT("plain_text_input"),
RADIO_BUTTONS("radio_buttons"),
CHECKBOXES("checkboxes"),
SELECT("select")
But always getting the exception of
not marked as ignorable (3 known properties: "actionId", "type", "text"])
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 12, column: 37] (through reference chain: configuration$Body["prefix"]->Prefix["aLevel"]->java.util.ArrayList[0]->xxx.$WidgetBase["placeholder"])
Can anyone help to fix this issue?
@Data
public static class Prefix {
@JsonProperty("aLevel")
private List<WidgetBase> aLevel;
}
@Data
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = TextInput.class, name = "plain_text_input"),
@JsonSubTypes.Type(value = RadioGroup.class, name = "radio_buttons"),
@JsonSubTypes.Type(value = Select.class, name = "select"),
@JsonSubTypes.Type(value = CheckBoxGroup.class, name = "checkboxes")
})
public static class WidgetBase {
@JsonProperty("actionId")
private String actionId;
@JsonProperty("type")
private DataType type;
@JsonProperty("text")
private String text;
}
@Data
public static class TextInput extends WidgetBase {
@JsonProperty("placeholder")
private String placeholder;
@JsonProperty("description")
private String description;
}
@Data
public static class CheckBoxGroup extends WidgetBase {
@JsonProperty("options")
private List<CheckBoxOption> option_items;
}
@Data
public static class Select extends WidgetBase {
@JsonProperty("selected_item")
private Option selected_item;
@JsonProperty("select_items")
private List<Option> select_items;
}
@Data
public static class Option {
@JsonProperty("text")
private String text;
@JsonProperty("value")
private String value;
}
and the payload can be as follow
"prefix":{
"aLevel":[
{
"actionId":"plain_text_input_3",
"type":"plain_text_input",
"text":"Account ID",
"placeholder":"Input your Account ID",
"description":"Please enter the Account ID"
},
{
"actionId":"radio_group_action_3",
"type":"radio_buttons",
"text":"Radio Select",
"initial_option":{
"text":"Radio 1",
"value":"value1"
},
"option_items":[
{
"text":"Option 1",
"value":"value1"
},
{
"text":"Option 2",
"value":"value2"
},
{
"text":"Option 3",
"value":"value3"
}]
},
{
"actionId":"checkbox_action_3",
"text":"Checkbox Group",
"type":"checkboxes",
"options":[
{
"text":"Option 1",
"value":"value1",
"initial_selected":true
}]
},
{
"actionId":"select_action_3",
"type":"select",
"text":"This is static select label",
"selected_item":{
"text":"Option 1",
"value":"value1"
},
"select_items":[
{
"text":"Option 1",
"value":"value1"
},
{
"text":"Option 2",
"value":"value2"
},
{
"text":"Option 3",
"value":"value3"
}
]}
}