![JAR search and dependency download from the Maven repository](/logo.png)
net.mossol.bot.util.MossolUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of line_bot_mossol-lib Show documentation
Show all versions of line_bot_mossol-lib Show documentation
Line Bot Mossol (line_bot_mossol-lib)
package net.mossol.bot.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.mossol.bot.model.LineRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by Amos.Doan.Mac on 2017. 12. 6..
*/
public final class MossolUtil {
private static final Logger logger = LoggerFactory.getLogger(MossolUtil.class);
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
public static LineRequest readJsonString(JsonNode jsonNode) {
try {
LineRequest request;
request = OBJECT_MAPPER.treeToValue(jsonNode, LineRequest.class);
return request;
} catch (Exception e) {
logger.debug("[ERROR] Converting to object failed. Received Json String <{}> cause : <{}>",
jsonNode,
e.getMessage());
return null;
}
}
public static String writeJsonString(Object obj) {
try {
if (obj == null) {
return null;
}
return OBJECT_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy