6

Object强制转换为List

 3 years ago
source link: https://blog.csdn.net/xiaogunagmei/article/details/111873315
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Object强制转换为List

1.采过的坑

java中如果是直接将某个对象强转成List,是无法强转成功的!

想将上面的 json 对象中的 BUSINESSCONTENT获取之后转成 List对象

代码如下:

List<Configure> configures = (List<Configure>) businesscontent;

这种直接转换是有问题的,代码如下,我们运行调试下:

调试结果如下:

2.改正如下:

定义一个方法强转Object到List

JSONObject是Alibaba的fastJson包

调试结果如下:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK