Skip to content

Commit

Permalink
Remove unnecessary json conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
milderhc committed Jul 24, 2024
1 parent 4f1bf1a commit b5e1b29
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ public RedisVectorStoreRecordMapper<Record> build() {

return new RedisVectorStoreRecordMapper<>(record -> {
try {
String json = mapper.writeValueAsString(record);
ObjectNode jsonNode = (ObjectNode) mapper.readTree(json);
ObjectNode jsonNode = mapper.valueToTree(record);
String key = jsonNode.get(keyFieldName).asText();
jsonNode.remove(keyFieldName);

return new AbstractMap.SimpleEntry<>(key, jsonNode);
} catch (JsonProcessingException e) {
} catch (Exception e) {
throw new SKException(
"Failure to serialize object, by default the Redis connector uses Jackson, ensure your model object can be serialized by Jackson, i.e the class is visible, has getters, constructor, annotations etc.",
e);
Expand Down

0 comments on commit b5e1b29

Please sign in to comment.