I need to create a JSON string as below using Jackson. I know similar question has been answered already here: Creating a json object using jackson
But my expected JSON string is a little different from the one in above example.
How can I form the below formatted JSON object in Java using only Jackson? Also, I do not prefer creating a separate POJO to achieve this.
Expected Output:
{
"obj1": {
"name1": "val1",
"name2": "val2"
},
"obj2": {
"name3": "val3",
"name4": "val4"
},
"obj3": {
"name5": "val5",
"name6": "val6"
}
}