All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anodoc.util.mapper.pds.StringPropertyDeserializer Maven / Gradle / Ivy

There is a newer version: 4.3.0
Show newest version
package net.anotheria.anodoc.util.mapper.pds;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import net.anotheria.anodoc.data.StringProperty;

import java.io.IOException;

/**
 * @author ykalapusha
 */
public class StringPropertyDeserializer extends StdDeserializer {

    public StringPropertyDeserializer() {
        this(null);
    }

    public StringPropertyDeserializer(Class vc) {
        super(vc);
    }

    @Override
    public StringProperty deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
        JsonNode node = jp.getCodec().readTree(jp);
        String nameId = node.get("id").textValue();
        String value = node.get("value").textValue();

        return new StringProperty(nameId, value);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy