Try to search your question here, if you can't find : Ask Any Question Now ?

How to de/serialize an instance with dynamically typed attribute

HomeCategory: stackoverflowHow to de/serialize an instance with dynamically typed attribute
Avatarwillson asked 4 months ago

What would be the best way to serialize/deserialize instances of MyClass using Jackson?

class MyClass {
    private String name;
    private MyInterface classInstance;

    // standard getters setters
}

Attribute classInstance can be of an arbitrary type which implements interface MyInterface

Ideally I’d like the yaml structure to look like this

name: com.example.ClassE
classInstance: 
  value: 42
  category: "fancy"

Notice that the “name” attribute actually contains a fully qualified type of the object inside “classInstance” attribute.

1 Answers
Best Answer
AvatarMatthias answered 4 months ago
Your Answer

9 + 12 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com