Skip to content
欢迎扫码关注公众号

Java 泛型的反序列化

将反序列化的类型改成泛型后显示写法不对。

本来用的 JSONObject 反序列化的:

java
JSONObject.toBean(JSONObject.fromObject(strJson), ClassA.class)

但是改成 ClassA<ClassB>.class 时编译出错。

后来参照 Java 泛型和 JSON 的反序列化(上)Java 泛型和 JSON 的反序列化(中)Java 泛型和 JSON 的反序列化(下) 改成了下面的形式。(使用 jacksonTypeReference 实现泛型的反序列化。)

java
ClassA<ClassB> apiResult  = new ObjectMapper().readValue(strJson, new TypeReference<ClassA<ClassB>>() { });

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.