猿问

无法将 JSON 值反序列化为类型

我试图在我的网络服务中反序列化一个 post 请求,但我最终得到一个 HTTP 500 说javax.json.bind.JsonbException: Error deserialize JSON value into type: class [C. 我正在使用 Jackson 来处理 JSON 内容。


这是我从 Postman 发送的 JSON 字符串:


{"firstName":"FirstName","middleName":"middleName","lastName":"LastName","name":"SomeName","password":"$0meR@nd0m","creationTimeStamp":1533950475466}  

这是我的 POJO :


@XmlRootElement

public class UserFormInterceptor   {

    @Pattern(regexp = "^[\\S][\\p{L} .'-]+$") @Size(min = 2, max = 64) @NotEmpty @NotNull

    private String firstName;

    @Pattern(regexp = "^[\\S][\\p{L} .'-]+$") @Size(min = 2, max = 64)

    private String middleName;

    @Pattern(regexp = "^[\\S][\\p{L} .'-]+$") @Size(min = 2, max = 64) @NotEmpty @NotNull

    private String lastName;

    @Pattern(regexp = "^[a-zA-z][\\w]*$") @Size(min = 8, max = 64) @NotEmpty @NotNull

    private String name;

    @Pattern(regexp = "(?=.*?[A-Z]+)(?=.*?[0-9]+)(?=.*?[\\p{Punct}]+).*") @Size(min = 8, max = 64) @NotEmpty @NotNull

    private char[] password;

    @Positive @NotEmpty @NotNull

    private long creationTimeStamp;


    public UserFormInterceptor() {}


    public UserFormInterceptor(@NotNull String name, @NotNull String password, @Positive long creationTimeStamp, @NotNull String firstName, String middleName, @NotNull String lastName) {

        this.name = name;

        this.password = password.toCharArray();

        this.creationTimeStamp = creationTimeStamp;

        this.firstName = firstName;

        this.middleName = middleName;

        this.lastName = lastName;

    }



    @NotNull

    public String getFirstName() {

        return firstName;

    }


    public void setFirstName(@NotNull String firstName) {

        this.firstName = firstName;

    }


    public String getMiddleName() {

        return middleName;

    }


    public void setMiddleName(String middleName) {

        this.middleName = middleName;

    }


    @NotNull

    public String getLastName() {

        return lastName;

    }


    public void setLastName(@NotNull String lastName) {

        this.lastName = lastName;

    }



牛魔王的故事
浏览 239回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答