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 ActivityIdDeserializer extends JsonDeserializer { @Override public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken jsonToken = p.getCurrentToken(); if (jsonToken == JsonToken.START_OBJECT) { JsonNode node = p.getCodec().readTree(p); return node.get("id").textValue(); } return p.getValueAsString(); } }