I am trying to create a nested JSON payload. I've done this by:
1) Creating initial map for the nested part
nested = Map();
nested.put("Full_Name",full_name);
...
2) Creating the main map:
mdoc = Map();
mdoc.put("document_template_id",templateid);
mdoc.put("payload",nested.toJsonList());
mdoc.put("status","pending");
This gives a payload like this:
- {"document":{"document_template_id":"E462EFC4-5B83-4A8E-B7DF-E54BB7D62411","payload":[{"Full_Name":"Bob Holness"}],"status":"pending"}}
This would usually be fine, but for some reason they want the nested element needs to be separated by \" rather than just " - e.g.
- {"document":{"document_template_id":"E462EFC4-5B83-4A8E-B7DF-E54BB7D62411","payload":[{\"Full_Name\":\"Bob Holness\"}],"status":"pending"}}
Is there an easy way to do this?
Help greatly appreciated.
Kind regards
Matt