Example usage for com.fasterxml.jackson.core JsonParser getValueAsString

List of usage examples for com.fasterxml.jackson.core JsonParser getValueAsString

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonParser getValueAsString.

Prototype

public String getValueAsString() throws IOException, JsonParseException 

Source Link

Document

Method that will try to convert value of current token to a java.lang.String .

Usage

From source file:com.codepine.api.testrail.internal.StringToMapDeserializer.java

@Override
public Map<String, String> deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    if (jp.getValueAsString() == null) {
        return null;
    }/*from ww  w .  j  a v  a 2  s .com*/
    Map<String, String> items = Splitter.on("\n").omitEmptyStrings().withKeyValueSeparator(',')
            .split(jp.getValueAsString());
    items = Maps.transformValues(items, new Function<String, String>() {
        @Override
        public String apply(String value) {
            return value.trim();
        }
    });
    return items;
}

From source file:com.vino.serialization.ReferenceDeserializer.java

@Override
public Reference deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    String key = jsonParser.getValueAsString();
    return new Reference(key);
}

From source file:craterdog.security.mappers.PublicKeyDeserializer.java

@Override
public PublicKey deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    PublicKey publicKey = manager.decodePublicKey(p.getValueAsString());
    return publicKey;
}

From source file:com.arpnetworking.configuration.jackson.akka.ActorRefDeserializer.java

/**
 * {@inheritDoc}/*  ww  w. ja  v a2 s  .c o  m*/
 */
@Override
public ActorRef deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
    return _system.provider().resolveActorRef(p.getValueAsString());
}

From source file:org.apache.streams.jackson.StreamsDateTimeDeserializer.java

/**
 * Applies each additional format in turn, until it can provide a non-null DateTime
 *///from  w w  w .  j  a  va 2  s . c o m
@Override
public DateTime deserialize(JsonParser jpar, DeserializationContext context) throws IOException {

    DateTime result = RFC3339Utils.parseToUTC(jpar.getValueAsString());
    Iterator<DateTimeFormatter> iterator = formatters.iterator();
    while (result == null && iterator.hasNext()) {
        DateTimeFormatter formatter = iterator.next();
        result = formatter.parseDateTime(jpar.getValueAsString());
    }
    return result;
}

From source file:org.dswarm.graph.json.deserializer.PredicateDeserializer.java

@Override
public Predicate deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final String predicateUri = jp.getValueAsString();

    if (predicateUri == null) {

        return null;
    }//w  w  w.  j a v  a  2 s  .  c  o m

    return new Predicate(predicateUri);
}

From source file:com.xeiam.xchange.utils.jackson.BooleanDeserializer.java

@Override
public Boolean deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    String valueAsString = jp.getValueAsString();
    if (trueValue.equals(valueAsString)) {
        return true;
    } else if (falseValue.equals(valueAsString)) {
        return false;
    }//w  w w  . j  a v a  2  s .co m
    throw new InvalidFormatException(
            String.format("Unrecognized value; expected %s or %s: %s", trueValue, falseValue, valueAsString),
            valueAsString, Boolean.class);
}

From source file:org.trustedanalytics.cloud.cc.api.utils.UuidJsonDeserializer.java

@Override
public UUID deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {

    try {/*from   w w  w .j ava2s.  c  o m*/
        return UUID.fromString(jsonParser.getValueAsString());
    } catch (IllegalArgumentException e) {
        LOGGER.debug("Unable to deserialize GUID: {}, exception: {}", jsonParser.getValueAsString(), e);
        return ARTIFICIAL_USER_GUID;
    }
}

From source file:com.perfly.android.core.json.DrawableDeserializer.java

@Override
public Drawable deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    return ImageUtils.base64ToDrawable(jsonParser.getValueAsString());
}

From source file:jenkins.plugins.sonarparser.utils.JodaDateTimeDeserializer.java

@Override
public DateTime deserialize(JsonParser jp, DeserializationContext dc)
        throws IOException, JsonProcessingException {
    return JodaDateTimeModule.FORMATTER.parseDateTime(jp.getValueAsString());
}