Since I’m writing a longer article and as I’m damn slow to write it, I wanted to go for a fast, short, milestone article about something I made recently.
As I wanted to craft my JSON data payload to send to an API for test purposes, I had multiple big objects coming from Java application that I wanted to convert to JSON instead of writing the payload with my bare hands. So I dug a bit into IntelliJ debug features and couldn’t transform the data output to JSON format.
I saw that you can define custom views (aka. renderers) to be used to apply a process on a variable/expression to transform the output shown in debug window.
To do so, it’s actually simple. Right click on the variable you want to display differently in your debug window, and then select one of the following options :
Customize data views : if you want to add a renderer for Object subtypes by default. Anyway you can change target objects types in both ways.
View as > Create : if you want to add a renderer by default for the select variable type.
Then, the following window is showing up :
You just have to specify a name, an entry type, and the rendering expression. Here, my concern was to show JSON, so I used Jackson ObjectMapper() object to convert my instance into JSON String with following expression :
That’s it ! when I select this renderer, I can see my output being transformed. Just have to copy value and paste it as a payload in my REST Client program, and do so for every other payloads I want to test ! Thanks again IntelliJ, for being such a great customizable IDE