Java Code Examples for com.fasterxml.jackson.databind.DeserializationContext#handleWeirdStringValue()
The following examples show how to use
com.fasterxml.jackson.databind.DeserializationContext#handleWeirdStringValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimestampDeserializer.java From act-platform with ISC License | 6 votes |
@Override public Long deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { // Input is already a long, just return value directly. if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { return p.getLongValue(); } // Try to convert input to an Instant, else throw an InvalidFormatException. if (p.hasToken(JsonToken.VALUE_STRING)) { try { return Instant.parse(p.getText()).toEpochMilli(); } catch (DateTimeParseException ignored) { return (Long) ctxt.handleWeirdStringValue(Long.class, p.getText(), "Cannot convert to valid Instant timestamp"); } } // Cannot handle input, throw a MismatchedInputException. return (Long) ctxt.handleUnexpectedToken(Long.class, p); }
Example 2
Source File: UUIDDeserializer.java From lams with GNU General Public License v2.0 | 4 votes |
private UUID _badFormat(String uuidStr, DeserializationContext ctxt) throws IOException { return (UUID) ctxt.handleWeirdStringValue(handledType(), uuidStr, "UUID has to be represented by standard 36-char representation"); }