JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String
在使用Postman測試Spring Boot專案介面時,介面返回JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String錯誤,如下圖:
引數使用JSON格式,POST請求,如下圖:
createTime變數使用了字串型別,介面接收引數後將該字串轉為日期時,發生錯誤,專案中使用fastjson來處理json資料。
此問題解決方法
在接收引數實體類的createtime欄位新增JsonFormat註解
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
如下圖:
專案重啟,再次請求,如果如下:
請求成功,如果使用了Timestamp型別來介面,有可能會報下面的異常:
JSON parse error: Can not deserialize value of type java.sql.Timestamp from String
這時,使用上面的方法也可解決問題。
相關文章
- Java更新資料庫報錯:Data truncation: Cannot create a JSON value from a string with CHARACTER SETJava資料庫JSON
- from type [java.lang.String] to type [org. apache.kafka.clients.consumer.ConsumerRecord<? ?>JavaApacheKafkaclient
- ImportError: cannot import name parseImportError
- parse-jsonJSON
- 如何解決"Parse error: syntax error"Error
- JSON.parse()方法JSON
- JSON.parse() 方法JSON
- cannot convert (type interface {}) to type int: need type assertion
- xxx cannot be resolved to a type
- [Vue warn]: Invalid prop: type check failed for prop "unlinkPanels". Expected Boolean, got String with value "true".VueAIBooleanGo
- [20230104]Oracle too many parse errors PARSE ERROR.txtOracleError
- 【譯】Flutter :Parse JSON in the backgroundFlutterJSON
- JSON.parse與JSON.stringify(object)JSONObject
- SpringBoot升級到3.2.0報錯Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.StringSpring BootBeanObjectJava
- Excel匯入資料異常Cannot get a text value from a numeric cell解決辦法Excel
- XML DOM Parse Error 物件概述XMLError物件
- Go 中 type var string 和 type var = string 的區別Go
- JSON.parse 和 JSON.stringify 詳解JSON
- vue報錯:[Vue warn]: Invalid prop: type check failed for prop "value". Expected Number, got String....VueAIGo
- JSON.parse 新手入門JSON
- Cannot set property ‘type‘ of null(vue)NullVue
- 有意思的JSON.parse()、JSON.stringify()JSON
- cannot access local variable where it is not associated with a value
- Construct String from Binary TreeStruct
- JSON.parse()出錯解決JSON
- 查LOB文字內容報錯ORA-06502: numeric or value error: character string buffer..Error
- ‘error: ‘‘this‘‘ cannot be implicitly captured in this context‘ErrorAPTContext
- Uncaught Error: Cannot instantiate interfaceError
- 7.107 JSON Type ConstructorJSONStruct
- MapStruct-plus cannot find converter fromStruct
- 帝國CMS提示parse error syntax error的解決方法Error
- error: 'cout' does not name a type|Error
- error: ‘xxx’ does not name a typeError
- Error-Expected resource of typeError
- Syntax error, unrecognized expression: li[value=]ErrorZedExpress
- 如何實現一個JSON.parseJSON
- JSON.parse () 的非嚴格模式JSON模式
- QSocketNotifier: Socket notifiers cannot be enabled or disabled from another