please help me to create the body request from the following output:
{
"categories": [
{
"categoryId": "4654-456465-4564",
"fields": {
"4564654-454646-4564": "Ano",
"4564654-454646-4561": "Super"
}
}
],
"lastUpdate": "1231",
"controlStructureId": "4654-456465-4564",
"controlId": "4654-456465-4564",
"vehicleId": "4654-456465-4564"
}
My code here, but It's not correct, because I have unwanted [ ] in * fields* section
public void testPOST() {
Map<String, Object> jsonBodyUsingMap = new HashMap<String, Object>();
jsonBodyUsingMap.put("categories", Collections.singletonList(new HashMap<String, Object>() {
{
put("categoryId", "4654-456465-4564");
put("fields", Arrays.asList(new HashMap<String, Object>() {{
put("4564654-454646-4561", "Super");
put("4564654-454646-4564", "Ano");
}}
));
}
}
));
jsonBodyUsingMap.put("lastUpdate", "1231");
jsonBodyUsingMap.put("controlStructureId", "4654-456465-4564");
jsonBodyUsingMap.put("controntrolId", "4654-456465-4564");
jsonBodyUsingMap.put("vehicleId", "4654-456465-4564");