I've below JSON string:
{ "students" : "[ {\"studentId\" : \"A1\",\"studentNumber\"
: \"287\",\"studentType\" : \"FullTime\"} ]" }
In order to deserialize this string in java object, I've to remove \ which can be done using string replace method. Apart from that there are double quotes also just before [ and after ]. how do I remove these double quotes or allow them while deserializeing using Jackson.
You don't have to do it yourself, jackson will take care of it. Create a pojo class Student and you can write something like below:
ObjectMapper mapper = new ObjectMapper();
Student student = mapper.readValue(responseBody, Student.class);
Try to replace "[ with [ and ]" with ]
json = json.replaceAll("\"\\[","[");
json = json.replaceAll("\\]\"", "]");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With