在另一个 Jackson 解串器中使用 Jackson 解串器

Jor*_*rdi 5 java json jackson

我为我的 DigitalInput 和 Resource 类创建了一个自定义解串器。

数字输入包含一个List<Resource>.

所以我需要ResourceDeserializer在 my 中使用我的自定义DigitalInputDeserializer,但我不知道该怎么做。

public class DigitalInputDeserializer extends JsonDeserializer<DigitalInput> {

    @Override
    public DigitalInput deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {

        DigitalInput digitalInput = null;

        JsonNode node = p.getCodec().readTree(p);
        Date timestamp = Instant.parse(node.get("timestamp").asText()).toDate();
        String matter = node.get("matter").asText();
        String description = node.get("comment").asText();
        //...

        JsonNode resources = node.get("resources");
        //???

        return digitalInput;
    }
}
Run Code Online (Sandbox Code Playgroud)

所以,你可以猜到,resources 是一个 json 数组。为了反序列化Resource我已经实现了 aResourceDeserializer并且我想在这里使用它。

我能做些什么?谢谢大家。