Skip to content
Advertisement

How have RecursiveToStringStyle and JSON_STYLE using commons-lang3

I’m using the dependency:

JavaScript

I have the following objects:

JavaScript

And I need to log the content of the class X recursively to get the class Y as well and using the JSON style. That is my goal and this is the purpose of this question.

Approach 1:

JavaScript

Approach 1 result:

JavaScript

Approach 2:

JavaScript

Approach 2 result:

JavaScript

Successful Approach:

JavaScript

Successful Approach result (My goal):

JavaScript

Advertisement

Answer

I found the solution. I need to Override the method toString of each classes (X and Y in this case)

JavaScript

And now, with the approach 1 It’s working.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement