All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arextest.web.api.service.beans.String2Map Maven / Gradle / Ivy

There is a newer version: 0.7.0.1
Show newest version
package com.arextest.web.api.service.beans;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class String2Map implements Converter {

  @Autowired
  @Lazy
  private ObjectMapper objectMapper;

  @Override
  public Map convert(String source) {
    Map result = null;
    try {
      result = objectMapper.readValue(source, Map.class);
    } catch (JsonProcessingException e) {
    }
    return result;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy