I use Json-Jackson to serialize/deserialize my object and all goes well with built-in classes.
String, int, and so on are very good. But now I must serialize/deserialize an object built in a particular manner. Follow the declaration:
class A implements Serializable {
private String id;
private List<B> bobjs;
...getters & setters (but not for String id)
}
class B implements Serializable {
private String id;
private String label;
private List<C> cobjs;
...getters & setters (but not for String id)
}
class C implements Serializable {
private String id;
private String label;
private BigDecimal counts;
...getters & setters (but not for String id)
}
If I use the standard serializer/deserialize, it says to me an error message like " java.lang.UnsupportedOperationException..." so it cannot serialize/deserialize bobjs.
How can I do this in a general manner, so I do not write 3 serializer/deserializer, but only tell to Json-Jackson when encounter an object of type "List" it must serialize/deserialize it like an array (for example).
Thanks all!
PS I find examples on google, but they are only for simple object but not for List that are formed of List.. and so on.
The problem was due to a really deep object not serializable. Really deep and little. Thanks all.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.