Gamelib/src/main/java/uulm/teamname/marvelous/gamelibrary/json/JsonNodeUnwrapper.java

17 lines
491 B
Java

package uulm.teamname.marvelous.gamelibrary.json;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.JsonNode;
public class JsonNodeUnwrapper {
public static <T> T unwrap(JsonNode subNode, Class<T> type, ObjectCodec codec)
throws JsonProcessingException {
if (subNode != null) {
return codec.treeToValue(subNode, type);
}
return null;
}
}