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

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

Introduction

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

Prototype

public abstract String getText() throws IOException, JsonParseException;

Source Link

Document

Method for accessing textual representation of the current token; if no current token (before first call to #nextToken , or after encountering end-of-input), returns null.

Usage

From source file:org.basinmc.maven.plugins.minecraft.access.VisibilityJsonDeserializer.java

/**
 * {@inheritDoc}/*from ww  w. j a  v  a2s.c  o  m*/
 */
@Override
public Visibility deserialize(@Nonnull JsonParser jsonParser,
        @Nonnull DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    String name = jsonParser.getText().toUpperCase();

    if ("PACKAGE-PRIVATE".equals(name)) {
        return Visibility.PACKAGE_PRIVATE;
    }

    return Visibility.valueOf(name);
}

From source file:net.solarnetwork.util.JodaDateTimeDeserializer.java

@Override
public DateTime deserialize(JsonParser parser, DeserializationContext context)
        throws IOException, JsonProcessingException {
    return formatter.parseDateTime(parser.getText());
}

From source file:net.solarnetwork.util.JodaLocalDateDeserializer.java

@Override
public LocalDate deserialize(JsonParser parser, DeserializationContext context)
        throws IOException, JsonProcessingException {
    return formatter.parseLocalDate(parser.getText());
}

From source file:net.solarnetwork.util.JodaLocalTimeDeserializer.java

@Override
public LocalTime deserialize(JsonParser parser, DeserializationContext context)
        throws IOException, JsonProcessingException {
    return formatter.parseLocalTime(parser.getText());
}

From source file:com.cedarsoft.serialization.jackson.StringSerializer.java

@Nonnull
@Override/*from   w ww  . ja va 2  s. c  o  m*/
public String deserialize(@Nonnull JsonParser deserializeFrom, @Nonnull Version formatVersion)
        throws IOException, VersionException, JsonProcessingException {
    return deserializeFrom.getText();
}

From source file:net.solarnetwork.util.JodaLocalDateTimeDeserializer.java

@Override
public LocalDateTime deserialize(JsonParser parser, DeserializationContext context)
        throws IOException, JsonProcessingException {
    return formatter.parseLocalDateTime(parser.getText());
}

From source file:org.hyperledger.jackson.BIDDeserializer.java

@Override
public BID deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonToken t = jp.getCurrentToken();//from  w  w w.  j av a2s  . c  o m
    if (t == JsonToken.VALUE_STRING) {
        String hashString = jp.getText().trim();
        if (hashString.length() == 0) {
            return null;
        }

        return new BID(hashString);
    }

    throw ctxt.mappingException(handledType());
}

From source file:org.hyperledger.jackson.HashDeserializer.java

@Override
public Hash deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonToken t = jp.getCurrentToken();//from  w  w w.  j a  v  a  2  s.co  m
    if (t == JsonToken.VALUE_STRING) {
        String hashString = jp.getText().trim();
        if (hashString.length() == 0) {
            return null;
        }

        return new Hash(hashString);
    }

    throw ctxt.mappingException(handledType());
}

From source file:org.hyperledger.jackson.TIDDeserializer.java

@Override
public TID deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonToken t = jp.getCurrentToken();//from   ww w. jav a  2  s. c om
    if (t == JsonToken.VALUE_STRING) {
        String hashString = jp.getText().trim();
        if (hashString.length() == 0) {
            return null;
        }

        return new TID(hashString);
    }

    throw ctxt.mappingException(handledType());
}

From source file:org.hyperledger.jackson.ScriptDeserializer.java

@Override
public Script deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonToken t = jp.getCurrentToken();/*  w w  w .j  a  va  2 s . c om*/
    if (t == JsonToken.VALUE_STRING) {
        String scriptString = jp.getText().trim();
        if (scriptString.length() == 0) {
            return null;
        }

        return new Script(Base64.getDecoder().decode(scriptString));
    }

    throw ctxt.mappingException(handledType());
}