blob: a635ea95d97dbd17ee3b275602f1011dca1a3802 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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<String> {
@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();
}
}
|