Say I have following json:
{
"empName": "rameshp",
"designation": "SE1",
"skills": [
{
"id": 2,
"rating": 4,
"skillName": "Node.js 7",
"skillCategory": "Programming"
}
]
}
Now there could be multiple objects like above, so I want to reference above schema which can be generated from https://www.jsonschema.net, but I want to have the empName as object keys and above as value, so it will be an object with multiple unique keys (empName) and the value will be referencing above schema. Consider below example, when the POJO is serialized to JSON by Jackson
, it should be like below:
{
"rameshp": {
"empName": "rameshp",
"designation": "SE1",
"skills": [
{
"id": 2,
"rating": 4,
"skillName": "Node.js 7",
"skillCategory": "Programming"
}
]
},
"john": {
"empName": "john",
"designation": "SE2",
"skills": [
{
"id": 2,
"rating": 4,
"skillName": "Node.js 7",
"skillCategory": "Programming"
}
]
}
}
What should be the overall schema for this scenario (the JSON schema)? Ultimately, jackson will be used to generate the POJO for this schema and used in the REST APIs that I have created.
EDIT: (trying to clarify)
Imagine a List<Map<k, v>>
as my data. I want to have json schema for this whose output json will have the keys as the object names, like above json example.
Solution: Mushif's comment to this question is the answer. For the value part, jsonschema can be used. Map<String, EmployeeDTO>