diff --git a/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/ContentMapper.java b/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/ContentMapper.java index 9c8d9f02f..68dc055d3 100644 --- a/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/ContentMapper.java +++ b/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/ContentMapper.java @@ -344,9 +344,6 @@ public MapperFacade getAutoMapper() { * @return ObjectMapper that has been configured to handle the segue recursive object model. */ public ObjectMapper generateNewPreconfiguredContentMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - ContentBaseDeserializer contentDeserializer = new ContentBaseDeserializer(); contentDeserializer.registerTypeMap(jsonTypes); @@ -368,9 +365,10 @@ public ObjectMapper generateNewPreconfiguredContentMapper() { contentDeserializerModule.addDeserializer(Choice.class, choiceDeserializer); contentDeserializerModule.addDeserializer(Item.class, itemDeserializer); contentDeserializerModule.addDeserializer(QuestionValidationResponse.class, validationResponseDeserializer); - contentDeserializerModule.addDeserializer( - LLMMarkingExpression.class, new LLMMarkingExpressionDeserializer(objectMapper)); + contentDeserializerModule.addDeserializer(LLMMarkingExpression.class, new LLMMarkingExpressionDeserializer()); + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); objectMapper.registerModule(contentDeserializerModule); return objectMapper; diff --git a/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/LLMMarkingExpressionDeserializer.java b/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/LLMMarkingExpressionDeserializer.java index 47116926e..a689f90b8 100644 --- a/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/LLMMarkingExpressionDeserializer.java +++ b/src/main/java/uk/ac/cam/cl/dtg/segue/dao/content/LLMMarkingExpressionDeserializer.java @@ -14,15 +14,10 @@ import java.io.IOException; public class LLMMarkingExpressionDeserializer extends JsonDeserializer { - private final ObjectMapper objectMapper; - - public LLMMarkingExpressionDeserializer(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - } - @Override public LLMMarkingExpression deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { + ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec(); ObjectNode root = objectMapper.readTree(jsonParser); if (null == root.get("type")) {