@Override public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { try { return super.deserialize(jp, ctxt); } catch (Exception ex) { return null; } } }
@SuppressWarnings("unchecked") @Override public EnumSet<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // Ok: must point to START_ARRAY (or equivalent) if (!jp.isExpectedStartArrayToken()) { throw ctxt.mappingException(EnumSet.class); } EnumSet result = constructSet(); JsonToken t; while ((t = jp.nextToken()) != JsonToken.END_ARRAY) { /* What to do with nulls? Fail or ignore? Fail, for now * (note: would fail if we passed it to EnumDeserializer, too, * but in general nulls should never be passed to non-container * deserializers) */ if (t == JsonToken.VALUE_NULL) { throw ctxt.mappingException(_enumClass); } Enum<?> value = _enumDeserializer.deserialize(jp, ctxt); result.add(value); } return result; }