Skip to content

Commit

Permalink
refactor: Object Mapper를 static 변수로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Sep 26, 2023
1 parent d07a72f commit 761c041
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class JsonView implements View {

private final ObjectMapper objectMapper = new ObjectMapper();
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Override
public void render(final Map<String, ?> model, final HttpServletRequest request,
Expand All @@ -22,8 +22,8 @@ public void render(final Map<String, ?> model, final HttpServletRequest request,

private String convertModel(final Map<String, ?> model) throws JsonProcessingException {
if (model.size() == 1) {
return objectMapper.writeValueAsString(model.values().toArray()[0]);
return OBJECT_MAPPER.writeValueAsString(model.values().toArray()[0]);
}
return objectMapper.writeValueAsString(model);
return OBJECT_MAPPER.writeValueAsString(model);
}
}

0 comments on commit 761c041

Please sign in to comment.