package com.juick.server.api.activity.helpers; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; import java.io.IOException; public class LinkValueDeserializer extends JsonDeserializer { @Override public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken jsonToken = p.getCurrentToken(); if (jsonToken == JsonToken.VALUE_STRING) { return p.getValueAsString(); } JsonNode node = p.getCodec().readTree(p); return node.get("href").textValue(); } }