Search in sources :

Example 16 with ObjectCodec

use of com.fasterxml.jackson.core.ObjectCodec in project shifu by ShifuML.

the class MultipleClassificationDeserializer method deserialize.

/*
     * (non-Javadoc)
     * 
     * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser,
     * com.fasterxml.jackson.databind.DeserializationContext)
     */
@Override
public MultipleClassification deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);
    for (MultipleClassification value : MultipleClassification.values()) {
        if (value.name().equalsIgnoreCase(node.textValue())) {
            return value;
        }
    }
    return null;
}
Also used : MultipleClassification(ml.shifu.shifu.container.obj.ModelTrainConf.MultipleClassification) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec)

Example 17 with ObjectCodec

use of com.fasterxml.jackson.core.ObjectCodec in project shifu by ShifuML.

the class NormTypeDeserializer method deserialize.

/*
     * (non-Javadoc)
     * 
     * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser,
     * com.fasterxml.jackson.databind.DeserializationContext)
     */
@Override
public NormType deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);
    for (NormType value : NormType.values()) {
        if (value.name().equalsIgnoreCase(node.textValue())) {
            return value;
        }
    }
    return null;
}
Also used : NormType(ml.shifu.shifu.container.obj.ModelNormalizeConf.NormType) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec)

Example 18 with ObjectCodec

use of com.fasterxml.jackson.core.ObjectCodec in project cas by apereo.

the class X509CertificateCredentialJsonDeserializer method deserialize.

@Override
public X509CertificateCredential deserialize(final JsonParser jp, final DeserializationContext deserializationContext) throws IOException {
    final ObjectCodec oc = jp.getCodec();
    final JsonNode node = oc.readTree(jp);
    final List<X509Certificate> certs = new ArrayList<>();
    node.findValues("certificates").forEach(n -> {
        final String cert = n.get(0).textValue();
        final byte[] data = EncodingUtils.decodeBase64(cert);
        certs.add(CertUtils.readCertificate(new InputStreamResource(new ByteArrayInputStream(data))));
    });
    final X509CertificateCredential c = new X509CertificateCredential(certs.toArray(new X509Certificate[] {}));
    return c;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) X509CertificateCredential(org.apereo.cas.adaptors.x509.authentication.principal.X509CertificateCredential) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec) X509Certificate(java.security.cert.X509Certificate) InputStreamResource(org.springframework.core.io.InputStreamResource)

Example 19 with ObjectCodec

use of com.fasterxml.jackson.core.ObjectCodec in project ocvn by devgateway.

the class GeoJsonPointDeserializer method deserialize.

@Override
public GeoJsonPoint deserialize(final JsonParser jsonParser, final DeserializationContext ctxt) throws IOException {
    ObjectCodec objectCodec = jsonParser.getCodec();
    JsonNode jsonNode = objectCodec.readTree(jsonParser);
    ArrayNode coordinate = (ArrayNode) jsonNode.get("coordinates");
    return new GeoJsonPoint(coordinate.get(0).asDouble(), coordinate.get(1).asDouble());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint)

Example 20 with ObjectCodec

use of com.fasterxml.jackson.core.ObjectCodec in project CzechIdMng by bcvsolutions.

the class GuardedStringDeserializer method deserialize.

/**
 * {@inheritDoc}
 */
@Override
public GuardedString deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    return new GuardedString(node.asText());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec)

Aggregations

ObjectCodec (com.fasterxml.jackson.core.ObjectCodec)21 JsonNode (com.fasterxml.jackson.databind.JsonNode)18 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ArrayList (java.util.ArrayList)2 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)2 JsonParser (com.fasterxml.jackson.core.JsonParser)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IAE (io.druid.java.util.common.IAE)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 URI (java.net.URI)1 X509Certificate (java.security.cert.X509Certificate)1 List (java.util.List)1 SSLContext (javax.net.ssl.SSLContext)1 RunMode (ml.shifu.shifu.container.obj.ModelBasicConf.RunMode)1