Search in sources :

Example 1 with NYTimesMultimedium

use of io.realm.examples.newsreader.model.entity.NYTimesMultimedium in project realm-java by realm.

the class RealmListNYTimesMultimediumDeserializer method deserialize.

@Override
public List<NYTimesMultimedium> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    RealmList<NYTimesMultimedium> list = new RealmList<>();
    TreeNode treeNode = jp.getCodec().readTree(jp);
    if (!(treeNode instanceof ArrayNode)) {
        return list;
    }
    ArrayNode arrayNode = (ArrayNode) treeNode;
    for (JsonNode node : arrayNode) {
        NYTimesMultimedium nyTimesMultimedium = objectMapper.treeToValue(node, NYTimesMultimedium.class);
        list.add(nyTimesMultimedium);
    }
    return list;
}
Also used : RealmList(io.realm.RealmList) TreeNode(com.fasterxml.jackson.core.TreeNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) NYTimesMultimedium(io.realm.examples.newsreader.model.entity.NYTimesMultimedium) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

TreeNode (com.fasterxml.jackson.core.TreeNode)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 RealmList (io.realm.RealmList)1 NYTimesMultimedium (io.realm.examples.newsreader.model.entity.NYTimesMultimedium)1