net.jmatrix.db.common.JSONUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsql Show documentation
Show all versions of jsql Show documentation
SQL Utilities including simple command line, schema management.
The newest version!
package net.jmatrix.db.common;
import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
public class JSONUtil {
public static U read(String s, Class u) throws IOException {
ObjectMapper om=new ObjectMapper();
om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
om.enable(SerializationFeature.INDENT_OUTPUT);
return om.readValue(s, u);
}
public static String write(Object o) throws IOException {
ObjectMapper om=new ObjectMapper();
om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
om.enable(SerializationFeature.INDENT_OUTPUT);
return om.writeValueAsString(o);
}
}