---
description: How to record complex objects in JAVA
---

# Recording complex objects

To use this feature, create a rdbDisplay file in the project root directory. It will store information about which methods to use to serialize objects. You can provide a customized method that serializes only relevant business logic data.

![RdbDisplay file](https://lh4.googleusercontent.com/kTqrJAhAKws4COUPOuQ4ndKCe2Ks7xeEuQgczjVb5k-rbKv13CbxewtFML2xtwxrgevCeLDqaYHhOCfbI2iLaox_q3tSVnBbv4ANVVT8pp0_5gNdDg_uBP-L5sOwNwDGYZtDH_0)

Each line in the file should contain information about a single type and the corresponding serialization method. The type name must include a full namespace and after a colon, it defines an object method or a fully qualified static method that accepts one parameter of the corresponding type, which RevDeBug will use to serialize the object content.

![](https://lh6.googleusercontent.com/LSpwR5Wp7VAO60zFBP2AJ7Yvo4F1nAbh1IPQD0CNfe2o9wfy1YAMkdN66f2rbpRw1yzYfnAtMgqlvsGFn4mCWrqiwI34VGffxi-3RqKFoxjBAQSE4nyenBFUrxPKCiNCXk-PuwQ)

In the above example, the toString method of the JSONObject object was used to serialize the content of JSONObject objects transmitted in the source code.&#x20;

In our demo application, the CalculateReconcilation(String id) method analyzes data from the JSON file. When using RevDeBug recording, the content of the analyzed file is preserved and visible while browsing the recording even if the file or the whole process no longer exists.&#x20;

Below is the result of such action shown in the RevDeBug interface:

![Value prompts - values overlayed on code](https://lh6.googleusercontent.com/pSyL3nNbUOm5Sy5FSkASz5X60lRk6nlQ_taZwbCMCFMhasK4pn5-BUyLtQbjdUUDmE8tDh9PHZ_ghZllzo810lES4AjOOOm3LOKs7CdRPEgQftpwOzOoQwxFZUoCzTUnhH1wFRg)

For 3rd party classes, where there is no suitable toString implementation you can povide an external serialization method by defining in a helper class a static public method receiving one parameter of this 3rd party object's type and returning a String representation. Assuming you would implement this method like in the example below:

```java
package com.mycompany.helpers;

public class toStringHelpers {
    public static String jsonObjectToString(org.json.simple.JSONObject obj) {
        return obj.toJSONString();
    }
}
```

you can then reference this helper method in the rdbDisplay file using the fully qualified name of the method and class it was implemented in like this:

{% code title="rdbDisplay" %}
```roboconf
org.json.simple.JSONObject:com.mycompany.helpers.toStringHelpers.jsonObjectToString
```
{% endcode %}



**Automatic Recording Complex Objects**

You can automate this process by adding these parameters for compiler to the build file :

{% tabs %}
{% tab title="Maven" %}
{% code title="pom.xml" %}
```xml
<arg>-AREVDEBUG_RDBDISPLAY_AUTOGEN=true</arg>
<arg>-AREVDEBUG_RDBDISPLAY_AUTOGEN_ARRAYS=true</arg>
<arg>-AREVDEBUG_RDBDISPLAY_AUTOGEN_COLLECTIONS=true</arg>
```
{% endcode %}
{% endtab %}

{% tab title="Gradle" %}
{% code title="build.gradle" %}
```java
"-AREVDEBUG_RDBDISPLAY_AUTOGEN=true",
"-AREVDEBUG_RDBDISPLAY_AUTOGEN_ARRAYS=true",
"-AREVDEBUG_RDBDISPLAY_AUTOGEN_COLLECTIONS=true"
```
{% endcode %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="381">Name</th><th>Explanation</th></tr></thead><tbody><tr><td>-AREVDEBUG_RDBDISPLAY_AUTOGEN</td><td><p><strong>Usage:</strong> Instructs RevDeBug Compiler to automatically generate RDBDisplay rules for every class in the compiled project (i.e. which compiler compiles) that overrides toString() method. This requires a performance consideration as RevDeBug will use implemented toString() methods to serialize the state of the object during runtime. </p><p><strong>Defaults to 'false'</strong> (do not generate RDBDisplay rules automatically).</p></td></tr><tr><td>-AREVDEBUG_RDBDISPLAY_AUTOGEN_ARRAYS=true</td><td><p><strong>Usage:</strong> Instructs RevDeBug Compiler to automatically generate RDBDisplay rules for displaying first elements of arrays of basic types (Integers, String, etc). This requires a performance consideration as RevDeBug will serialize the state of those arrays during runtime. </p><p><strong>Defaults to 'false'</strong> (do not generate RDBDisplay rules automatically).</p></td></tr><tr><td>-AREVDEBUG_RDBDISPLAY_AUTOGEN_COLLECTIONS=true</td><td><p><strong>Usage:</strong> Instructs RevDeBug Compiler to automatically generate RDBDisplay rules for displaying first elements of collections of basic types (Integers, String, etc). This requires a performance consideration as RevDeBug will serialize the state of those/ collections during runtime. </p><p><strong>Defaults to 'false'</strong> (do not generate RDBDisplay rules automatically).</p></td></tr></tbody></table>
