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:net.sf.mmm.orient.impl.id.OrientIdJsonDeserializer.java

@Override
public OrientId<?> deserialize(JsonParser p, DeserializationContext ctx)
        throws IOException, JsonProcessingException {

    String idAsString = p.getValueAsString();
    OrientId<?> orientId = OrientId.of(null, idAsString);
    if (orientId != null) {
        OrientBean beanPrototype = this.beanMapper.getBeanPrototype(orientId.getOrid().getClusterId());
        if (beanPrototype != null) {
            Class<? extends Bean> beanClass = beanPrototype.access().getBeanClass();
            orientId = orientId.withType(beanClass);
        }/*from   w  w w .  j a  v  a2  s. c  o  m*/
    }
    return orientId;
}

From source file:org.eyeseetea.malariacare.layout.dashboard.deserializers.DatabaseOriginTypeDeserializer.java

@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    DatabaseOriginType databaseOriginType = DatabaseOriginType.fromId(p.getValueAsString());
    if (databaseOriginType != null) {
        return databaseOriginType;
    }//from  w  w w  .  j av  a2  s  .c o  m
    throw new JsonMappingException("'originType' must be 'dhis' or 'csv'");
}

From source file:org.eyeseetea.malariacare.layout.dashboard.deserializers.DashboardListFilterDeserializer.java

@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    DashboardListFilter dashboardListFilter = DashboardListFilter.fromId(p.getValueAsString());
    if (dashboardListFilter != null) {
        return dashboardListFilter;
    }//  www . j  a  v  a 2 s. c o m
    throw new JsonMappingException("'listFilter' must be 'lastForOU' or 'none'");
}

From source file:org.eyeseetea.malariacare.layout.dashboard.deserializers.DashboardOrientationDeserializer.java

@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    DashboardOrientation dashboardOrientation = DashboardOrientation.fromId(p.getValueAsString());
    if (dashboardOrientation != null) {
        return dashboardOrientation;
    }//  www  .  j a v  a2  s. c  o  m
    throw new JsonMappingException("'orientation' must be 'horizontal' or 'vertical'");
}

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

@Override
public PrivateKey deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    PrivateKey privateKey = null;
    if (password != null) {
        privateKey = manager.decodePrivateKey(p.getValueAsString(), password);
    }//from   w  w  w .  ja  v  a  2s  .  com
    return privateKey;
}

From source file:fr.javatic.mongo.jacksonCodec.objectId.IdDeserializer.java

@Override
public String deserialize(JsonParser jsonParser, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    if (!(jsonParser instanceof BsonParser)) {
        return jsonParser.getValueAsString();
    }// ww  w  . j  a v  a2 s  .  c  o  m
    return deserialize((BsonParser) jsonParser, ctxt);
}

From source file:org.darkware.wpman.util.serialization.ThemeEnabledDeserializer.java

@Override
public Boolean deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    // Make sure the value isn't already a boolean-ish string.
    String strValue = jsonParser.getValueAsString();

    if ("network".equals(strValue))
        return Boolean.TRUE;
    if ("no".equals(strValue))
        return Boolean.FALSE;

    return Boolean.FALSE;
}

From source file:ch.rasc.wampspring.message.CallResultMessage.java

public CallResultMessage(JsonParser jp) throws IOException {
    super(WampMessageType.CALLRESULT);

    if (jp.nextToken() != JsonToken.VALUE_STRING) {
        throw new IOException();
    }//from   w ww  .  j ava2s.  com
    this.callID = jp.getValueAsString();

    jp.nextToken();
    this.result = jp.readValueAs(Object.class);
}

From source file:ch.rasc.wampspring.message.PrefixMessage.java

public PrefixMessage(JsonParser jp) throws IOException {
    super(WampMessageType.PREFIX);

    if (jp.nextToken() != JsonToken.VALUE_STRING) {
        throw new IOException();
    }/*w  ww  .  j  a  va2s  .c  o  m*/
    this.prefix = jp.getValueAsString();

    if (jp.nextToken() != JsonToken.VALUE_STRING) {
        throw new IOException();
    }
    this.uri = jp.getValueAsString();
}

From source file:io.gravitee.management.rest.mapper.ObjectMapperResolver.java

public ObjectMapperResolver() {
    mapper = new GraviteeMapper();

    SimpleModule module = new SimpleModule();
    module.setDeserializerModifier(new BeanDeserializerModifier() {
        @Override//ww  w  .  ja v  a 2  s .c o  m
        public JsonDeserializer<Enum> modifyEnumDeserializer(DeserializationConfig config, final JavaType type,
                BeanDescription beanDesc, final JsonDeserializer<?> deserializer) {
            return new JsonDeserializer<Enum>() {
                @Override
                public Enum deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
                    Class<? extends Enum> rawClass = (Class<Enum<?>>) type.getRawClass();
                    return Enum.valueOf(rawClass, jp.getValueAsString().toUpperCase());
                }
            };
        }
    });
    module.addSerializer(Enum.class, new StdSerializer<Enum>(Enum.class) {
        @Override
        public void serialize(Enum value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
            jgen.writeString(value.name().toLowerCase());
        }
    });
    mapper.registerModule(module);
}