請幫我這個降壓:無法將START_ARRAY標記的java.lang.String實例反序列化;
Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not deserialize instance of java.lang.String out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
at [Source: [email protected]; line: 1, column: 31]
我發送以下JSON請求:
{"title": "Test", "category": ["2","4","3",1], "description": "Test", "username": ""}
在 「類別」 欄中出現的錯誤。
我用一個PostgreSQL數據庫 和我有以下型號:
@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idea_seq")
@SequenceGenerator(name = "idea_seq", sequenceName = "idea_seq", allocationSize = 1)
private Integer id;
@Column(name = "TITLE", length = 100)
@NotNull
@Size(min = 1, max = 100)
private String title;
@Column(name = "CATEGORY", length = 10)
@NotNull
@Size(min = 1, max = 100)
private String[] category;
@Column(name = "DESCRIPTION", length = 1000)
@NotNull
@Size(min = 1, max = 1000)
private String description;
@Column(name = "USERNAME", length = 100)
@NotNull
@Size(min = 1, max = 100)
private String username;
我會很高興的任何幫助。我已經有這個bug幾天了。
發佈相關代碼,以及完整的excatption堆棧跟蹤。另外,修復你的JSON:',1]'應該是',「1」]'。 –
當我谷歌此錯誤消息在StackOverflow顯示了三個其他線程。你有沒有檢查過它們是否適合你的問題? – Lothar
嗨JB Nizet,我已經發布了整個異常堆棧跟蹤。什麼是你的相關代碼? @洛塔爾:你真的認爲我不會先檢查那些人嗎? – justus