我在JSON中使用的所有字符串都不能通过Spring Boot和Jackson 310反序列化为$UserData = json_decode(file_get_contents("php://input"), true);
。我尝试了以下所有内容:
但没有工作。我的DTO很简单,我尝试过:
LocalDateTime
我提交的JSON是:
@ApiModel
@Validated
public class DateRange implements Serializable
{
@ApiModelProperty
@NotNull
@JsonFormat( shape = JsonFormat.Shape.ANY, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT" )
protected LocalDateTime start;
@ApiModelProperty
@NotNull
@JsonFormat( shape = JsonFormat.Shape.ANY, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT" )
protected LocalDateTime end;
public DateRange()
{
}
public LocalDateTime getStart()
{
return start;
}
public void setStart(LocalDateTime start)
{
this.start = start;
}
public LocalDateTime getEnd()
{
return end;
}
public void setEnd(LocalDateTime end)
{
this.end = end;
}
@Override
public boolean equals(Object o)
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
DateRange range = ( DateRange ) o;
return Objects.equals( start, range.start ) && Objects.equals( end, range.end );
}
@Override
public int hashCode()
{
return Objects.hash( start, end );
}
}
我还在项目符号列表中尝试了上面发布的所有差异版本。
我做错了什么?
答案 0 :(得分:0)
包含json反序列化程序的此依赖项:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>