Here is how I am trying to convert an object to json String
ObjectNode batch = OBJECT_MAPPER.createObjectNode();
String s = OBJECT_MAPPER.writeValueAsString((triggerCommands.getCommands()));
batch.put("commands", s);
System.out.println("raw String= " + s);
System.out.println("ObjectNode String = " + batch);
Which results in output of;
raw String= [{"cmdid":"a06c00d4-5b8b-4313-a8f3-5663dde0fa5b","type":"test"}]
ObjectNode String = {"commands":"[{\"cmdid\":\"a06c00d4-5b8b-4313-a8f3-5663dde0fa5b\",\"type\":\"test\"}]"}
I am curious to know why the String gets backslash when I add it into as value of ObjectNode. All i want is
ObjectNode String = {"commands":[{"cmdid":"a06c00d4-5b8b-4313-a8f3-5663dde0fa5b","type":"test"}]}
There is a similar question asked here but has no solid answer that worked.