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
這時,使用上面的方法也可解決問題。
相關文章
- Error: Attribute application@label value=(@string/appname) from AndroidManifestErrorAPPAndroid
- PHP Fatal error: Cannot use PhpParser\Node\Scalar\String as StringPHPError
- ImportError: cannot import name parseImportError
- Error: cannot fetch last explain plan from PLAN_TABLEErrorASTAI
- The type XXX cannot be resolved.It is indirectly referenced from required .classUI
- java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy7 implemJavaException
- Value Type vs Reference Type in SwiftSwift
- 452 Error writing file: A file cannot be larger than the value set by ulimit.ErrorMIT
- parse-jsonJSON
- 如何解決"Parse error: syntax error"Error
- JSON.parse() 方法JSON
- JSON.parse()方法JSON
- cannot convert (type interface {}) to type int: need type assertion
- from type [java.lang.String] to type [org. apache.kafka.clients.consumer.ConsumerRecord<? ?>JavaApacheKafkaclient
- ERROR getting 'android:label' attribute: attribute is not a string valueErrorAndroid
- ORA-06502 PL/SQL: numeric or value error stringSQLError
- The type List is not generic; it cannot …
- Cannot infer type arguments for PageImpl
- 【譯】Flutter :Parse JSON in the backgroundFlutterJSON
- XML DOM Parse Error 物件概述XMLError物件
- JSON.parse(str),JSON.stringify(a)JSON
- JSON.parse()和JSON.stringify()JSON
- An error from listenerError
- Golang Cannot use ss(type AAA) as type AAA in map indexGolangIndex
- Go 中 type var string 和 type var = string 的區別Go
- ERROR 1548 (HY000): Cannot load from mysql.proc. The table is probably corruptedErrorMySql
- Cannot set property ‘type‘ of null(vue)NullVue
- [Vue warn]: Invalid prop: type check failed for prop "unlinkPanels". Expected Boolean, got String with value "true".VueAIBooleanGo
- MySQL ERROR 1366(HY000):Incorrect string value:''for column''at row 1解決方案MySqlError
- MySQL 亂碼實戰解決ERROR 1366 (HY000): Incorrect string value: 'MySqlError
- JSON.parse 新手入門JSON
- cannot access local variable where it is not associated with a value
- JSON.parse與JSON.stringify(object)JSONObject
- Excel匯入資料異常Cannot get a text value from a numeric cell解決辦法Excel
- vue報錯:[Vue warn]: Invalid prop: type check failed for prop "value". Expected Number, got String....VueAIGo
- error :does not name a typeError
- xxx cannot be resolved to a type
- JSON.parse()出錯解決JSON