java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to com.
前言
阿里json轉換報錯
java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to com.picc.vo.WxUserVo
問題
// List<WxUserVo> wxUserVos = (List<WxUserVo> )jsonObject.get("userlist");
Object userlist = jsonObject.get("userlist");
List<WxUserVo> wxUserVos = JSONObject.parseArray(userlist.toString(), WxUserVo.class);
原因
註釋部分轉換,的時候debug可以通過 但是迴圈一定會報錯,需要分成兩部,先拿到批量的json字串,在指定轉換型別,這樣就不會報錯,我覺得阿里可以優化下這個問題
相關文章
- com.alibaba.fastjson.JSONObject cannot be cast to XXX異常解決ASTJSONObject
- Cause: java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.ibatis.mapping.MappedStatementJavaASTExceptionApacheBATAPP
- 解決String cannot be cast to java.util.List報錯ASTJava
- SQL中欄位比較型別不匹配錯誤:‘cannot be cast to’SQL型別AST
- C++強制型別轉換:static_cast、dynamic_cast、const_cast、reinterpret_castC++型別AST
- 7.41 CASTAST
- springboot mybatis Java.lang.ClassCastExceptionSpring BootMyBatisJavaASTException
- reinterpret_cast 和 static_cast 的區別AST
- dynamic_castAST
- static_cast與dynamic_cast到底是什麼?AST
- 型別轉換(cast)型別AST
- reinterpret_cast解讀AST
- C++中dynamic_cast與static_cast淺析與例項演示C++AST
- static_cast和dynamic_cast的區別,看完這篇你就懂了!AST
- Hadoop中java.lang.ClassCastException: partition解決方法HadoopJavaASTException
- SQL中的cast()函式SQLAST函式
- SQL Server 2016 函式:CASTSQLServer函式AST
- (轉)Go 每日一庫之 castGoAST
- Golang 型別轉換庫 castGolang型別AST
- C++中型別轉換static_castC++型別AST
- jmeter分散式測試報錯Error in rconfigure() method java.lang.ClassCastExceptionJMeter分散式ErrorJavaASTException
- ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accuratelyErrorYAMLProject
- 解決cannot find module providing package或cannot find main modulePackageAI
- Golang:cast安全且易用的型別轉換工具GolangAST型別
- c++ static_cast顯式型別轉換C++AST型別
- xxx cannot be resolved to a type
- diskgroup "DATADG" cannot be mounted
- cannot instantiate QtProjectEngine objectQTProjectObject
- Cannot set property 'innerHTML' of nullHTMLNull
- ImportError: cannot import name parseImportError
- fork failed - Cannot allocate memoryAI
- ‘error: ‘‘this‘‘ cannot be implicitly captured in this context‘ErrorAPTContext
- Cannot read property ‘aDataSort‘ of undefinedUndefined
- Uncaught Error: Cannot instantiate interfaceError
- Cannot set property ‘type‘ of null(vue)NullVue
- Cannot access androidx.lifecycle.HasDefaultViewModelProviderFactoryAndroidViewIDE
- Warning: Cannot redeclare function_name()Function
- cannot import name '_psutil_linux'ImportLinux