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
willson asked 3 weeks 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
Matthias answered 3 weeks ago
Your Answer

18 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com