I'm writing restful API with Spring. The API looks like below which lists all objects of its type.
http://192.168.1.100:8021/some/api/v3/someobjs
The DTO looks like below
public class SomeDTO {
@NotBlank
@Size(min = 1, max = 32, message = "Name size must be between 1 and 32.")
private String name;
@NotBlank
@Size(min = 1, max = 4000, message = "Info size must be between 1 and 4000.")
private String info;
// Setter & Getter
}
The "info" value could be a JSON format string. So, what I got could be like this:
{
"name": "wpdfw",
"info": "{\n \"indexName\": \"wpdfw\", \n \"urls\": [\n \"https://www.example.com/l2/api/v1\", \n \"https://www.example.com/l3/api/v1\"\n ], \n \"regions\": [\n \"wp.*.*\", \n \"wf.*.*\"\n ], \n \"policy\": \"equal\"\n}"
}
However, I want the "info" to be in real JSON format instead of a string:
{
"name": "wpdfw",
"info": {
"indexName": "wpdfw",
"urls": ["https://www.example.com/l2/api/v1", "https://www.example.com/l3/api/v2"],
"regions": ["wp.*.*", "wf.*.*"],
"policy": "equal"
}
}
Please note that the JSON format "info" value could be of any JSON hierarchical structure which is unknown. How can I do it?