org.agmip.util.JSONAdapter Maven / Gradle / Ivy
package org.agmip.util;
/**
* Simple JSON converter using Jackson
*/
import java.io.IOException;
import java.util.HashMap;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JSONAdapter {
private static final ObjectMapper mapper = new ObjectMapper();
private static final Logger LOG = LoggerFactory.getLogger(JSONAdapter.class);
public static HashMap fromJSON(String json) throws IOException {
return mapper.readValue(json, new TypeReference>() {});
}
public static String toJSON(Object obj) throws IOException {
return mapper.writeValueAsString(obj);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy