| | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.core.util.BufferRecyclers; |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.slf4j.Logger; |
| | |
| | | } |
| | | } |
| | | |
| | | public static String toJson(String str) { |
| | | if (str == null) return ""; |
| | | return new String(BufferRecyclers.getJsonStringEncoder().quoteAsString(str)); |
| | | } |
| | | |
| | | public static <T> T fromJson(Class<T> clazz, String json) { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |