You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 5, 2019. It is now read-only.
I have a use case where we use CharacterEscapes to encode a few characters serialized with Jackson. The other side of the coin is that we've long used a simple JsonDeserializer to unencode these same characters. Basically, the intent being that by making an RO into JSON, then converting the JSON back into the RO, there's no changes that occur during the round trip.
Let's be more specific. I want to get the following test to pass. Is there any way that I can accomplish this?
@Test
public void ensureSimpleROCanGetCreatedWithUnescapedJSON() throws Exception {
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = // ...;
module.addDeserializer(String.class, ...);
module.addValueInstantiator(String.class, ...);
mapper.registerModule(new AfterburnerModule());
mapper.registerModule(module);
String jsonObject = "{\"field\": \"value & value\"}";
SimpleRO parsedRO = mapper.readValue(jsonObject, SimpleRO.class);
Assert.assertEquals("value & value", parsedRO.field);
}
private static class SimpleRO {
public String field;
}
Both the JsonDeserializer I have configured (implementing public String deserialize(JsonParser parser, DeserializationContext context) throws IOException) and the StdValueInstantiator I have configured (implementing public Object createFromString(DeserializationContext ctxt, String value) throws IOException) pass the strings through a method which does, basically return Pattern.compile("&").matcher(string).replaceAll("&");.
Without afterburner, this test passes. With, it fails. Any ideas?