io.virtualan.core.util.Converter Maven / Gradle / Ivy
package io.virtualan.core.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.virtualan.core.model.ContentType;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import io.virtualan.core.model.VirtualServiceKeyValue;
import io.virtualan.core.model.VirtualServiceRequest;
import io.virtualan.entity.VirtualServiceEntity;
@Component("converter")
public class Converter {
private static final String PARAM_DELIMITER = ":_:";
@Autowired
private ObjectMapper objectMapper;
private String getString(Object jsonObject) throws JsonProcessingException {
if(jsonObject != null && jsonObject instanceof LinkedHashMap) {
return objectMapper.writeValueAsString(jsonObject);
} else if (jsonObject != null && jsonObject instanceof String){
return jsonObject.toString();
}
return null;
}
private Object getJson(String jsonStr) {
if(jsonStr != null && !jsonStr.isEmpty()) {
try {
return objectMapper.readValue(jsonStr, new TypeReference
© 2015 - 2024 Weber Informatics LLC | Privacy Policy