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.create.databind.MoneyDeserializer.java

@Override
public BigDecimal deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {
    final String value = jsonParser.getValueAsString();
    return new BigDecimal(value).setScale(CURRENCY_SCALE, BigDecimal.ROUND_HALF_UP);
}

From source file:com.braisgabin.fbstats.helpers.DateDeserializer.java

@Override
public Date deserialize(final JsonParser parser, final DeserializationContext context) throws IOException {
    final String value = parser.getValueAsString();

    final Date date;
    try {//  w  w w .  j  av  a  2  s. com
        synchronized (dateFormat) {
            date = dateFormat.parse(value);
        }
    } catch (ParseException e) {
        throw new IOException(e);
    }

    return date;
}

From source file:com.cosmicpush.jackson.PushTypeDeserializer.java

@Override
public PushType deserialize(JsonParser jp, DeserializationContext context)
        throws IOException, JsonProcessingException {
    String code = jp.getValueAsString();
    return (code == null) ? null : PushType.find(code);
}

From source file:com.github.gabrielruiu.springsocial.yahoo.module.FieldTypeDeserializer.java

@Override
public FieldType deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    String fieldTypeString = jp.getValueAsString();
    return FieldType.valueOf(fieldTypeString.toUpperCase());
}

From source file:minium.cucumber.report.domain.JsonBase64Deserializer.java

@Override
public byte[] deserialize(JsonParser jsonParser, DeserializationContext context)
        throws IOException, JsonProcessingException {
    String value = jsonParser.getValueAsString();
    return Base64.decodeBase64(value);
}

From source file:org.zalando.jackson.datatype.money.CurrencyUnitDeserializer.java

@Override
public CurrencyUnit deserialize(final JsonParser parser, final DeserializationContext context)
        throws IOException {
    final String currencyCode = parser.getValueAsString();
    return Monetary.getCurrency(currencyCode);
}

From source file:com.smartsheet.api.internal.json.FormatDeserializer.java

@Override
public Format deserialize(JsonParser jsonParser, DeserializationContext ctx)
        throws IOException, JsonProcessingException {
    return new Format(jsonParser.getValueAsString());
}

From source file:com.tigerpenguin.places.deserializer.PlaceTypeDeserializer.java

@Override
public PlaceType deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {
    String value = jsonParser.getValueAsString();
    PlaceType placeType = PlaceType.UNKNOWN;
    try {/*from www  .j a  v  a2 s.c o m*/
        placeType = PlaceType.valueOf(value.toUpperCase(Locale.US));
    } catch (IllegalArgumentException iae) {
        Log.e(TAG, "Unknown PlaceType: " + value);
    }
    return placeType;
}

From source file:com.arpnetworking.tsdcore.statistics.StatisticDeserializer.java

/**
 * {@inheritDoc}//from ww  w  . ja va 2  s.  c o m
 */
@Override
public Statistic deserialize(final JsonParser parser, final DeserializationContext context) throws IOException {
    final String statisticNameOrAlias = parser.getValueAsString();
    return STATISTIC_FACTORY.getStatistic(statisticNameOrAlias);
}

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

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

    String str = jp.getValueAsString();
    try {/*from  w w  w  .  j  av a  2  s .co  m*/
        return dateFormat.parse(str);
    } catch (ParseException e) {
        throw new InvalidFormatException("Error parsing as date", str, Date.class);
    }
}