Example usage for com.fasterxml.jackson.core ObjectCodec readTree

List of usage examples for com.fasterxml.jackson.core ObjectCodec readTree

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core ObjectCodec readTree.

Prototype

public abstract <T extends TreeNode> T readTree(JsonParser jp) throws IOException, JsonProcessingException;

Source Link

Document

Method to deserialize JSON content as tree expressed using set of TreeNode instances.

Usage

From source file:org.openmhealth.schema.pojos.serialize.dates.ISODateDeserializer.java

@Override
public DateTime deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    return formatter.parseDateTime(node.asText());
}

From source file:org.openmhealth.schema.pojos.serialize.PositionDuringMeasurementDeserializer.java

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

    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    return PositionDuringMeasurement.valueForLabel(node.asText());
}

From source file:ml.shifu.shifu.container.obj.RunModeDeserializer.java

@Override
public RunMode deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);

    for (RunMode value : RunMode.values()) {
        if (value.name().equalsIgnoreCase(node.textValue())) {
            return value;
        }// w  ww . j  av a  2 s. c  o  m
    }
    return null;
}

From source file:ml.shifu.shifu.container.obj.SouceTypeDeserializer.java

@Override
public SourceType deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);

    for (SourceType value : SourceType.values()) {
        if (value.name().equalsIgnoreCase(node.textValue())) {
            return value;
        }/*from   ww w.  ja  v a2s .c om*/
    }
    return null;
}

From source file:com.pkrete.locationservice.admin.deserializers.LanguageJSONDeserializer.java

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

    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    int id = node.get("id") == null ? 0 : node.get("id").intValue();
    String name = node.get("name") == null ? "" : node.get("name").textValue();
    String code = node.get("code") == null ? "" : node.get("code").textValue();
    return new Language(id, name, code);
}

From source file:ml.shifu.shifu.container.obj.BinningMethodDeserializer.java

@Override
public BinningMethod deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);

    for (BinningMethod value : BinningMethod.values()) {
        if (value.name().equalsIgnoreCase(node.textValue())) {
            return value;
        }/*from   w ww. j a va 2  s.com*/
    }
    return null;
}

From source file:com.btmatthews.atlas.core.domain.jsr310.LocalDateTimeDeserializer.java

@Override
public LocalDateTime deserialize(final JsonParser parser, final DeserializationContext context)
        throws IOException {
    final ObjectCodec codec = parser.getCodec();
    final JsonNode node = codec.readTree(parser);
    return LocalDateTime.parse(node.asText(), DATE_TIME_FORMATTER);
}

From source file:br.com.itw.commons.json.JsonDateDeserializer.java

@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);

    try {//from ww w .  j  av a  2  s .co m
        return (Date) dateFormat.parse(node.asText());
    } catch (ParseException e) {
        try {
            return (Date) dateFormat2.parse(node.asText());
        } catch (ParseException e1) {
            throw new IOException(e);
        }

    }
}

From source file:com.btmatthews.atlas.core.dao.mongo.MongoLocalDateTimeDeserializer.java

@Override
public LocalDateTime deserialize(final JsonParser parser, final DeserializationContext context)
        throws IOException {
    final ObjectCodec codec = parser.getCodec();
    final JsonNode node = codec.readTree(parser);
    final JsonNode dateNode = node.get("$date");
    return LocalDateTime.parse(dateNode.asText(), DATE_TIME_FORMATTER);
}

From source file:com.pkrete.locationservice.admin.deserializers.JSJSONDeserializer.java

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

    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    // Parse id/*  ww w .  java 2 s .  c  om*/
    int id = node.get("id") == null ? 0 : node.get("id").intValue();
    // Parse filename
    String filename = node.get("filename") == null ? "" : node.get("filename").textValue();
    // Parse contents
    String contents = node.get("contents") == null ? null : node.get("contents").textValue();

    // Return new JS
    return new JS(id, filename, "", contents, null);
}