| 123456789101112131415161718192021222324 |
- package com.izouma.nineth.converter;
- import com.fasterxml.jackson.core.type.TypeReference;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import org.springframework.core.convert.converter.Converter;
- import org.springframework.stereotype.Component;
- import javax.annotation.Nullable;
- import java.io.IOException;
- import java.util.Map;
- @Component
- public class StringToMapConverter implements Converter<String, Map<String, Object>> {
- @Override
- public Map<String, Object> convert(@Nullable String source) {
- try {
- return new ObjectMapper().readValue(source, new TypeReference<Map<String, Object>>() {
- });
- } catch (IOException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
- }
|