I have a POJO.
@Data
@AllArgsConstructor
@Builder
public class Emp {
private String position;
private String name;
}
Suppose, we have created an object
Emp emp = new Emp("Manager", "Bob");
How can I convert it to a list and save it in a database in JSON format?
The data should be stored in the database in the format below:
{
list:[
{
position: Manager
name: Bob
}
]
}
Are there any ready solutions for that?
I converted an object into a list and then I called the .toString() method on it:
Collections.singletonList(emp);
But when I store it in the database, the next save goes to the database:
[Emp(position=Manager, name=Bob)]
But I need to store the record in a different way