Skip to content

Commit

Permalink
null fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshSingla committed Jul 24, 2024
1 parent a49b0af commit 98ea5bb
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JavaType;
Expand Down Expand Up @@ -124,21 +125,29 @@ public static void writeObjectUsingSerializerProvider(
}
}

@Nullable
public static <T> T readObjectUsingDeserializationContext(
final JsonParser jp,
final DeserializationContext deserializationContext,
final Class<T> clazz
) throws IOException
{
if (jp.currentToken() == JsonToken.VALUE_NULL) {
return null;
}
return deserializationContext.readValue(jp, clazz);
}

@Nullable
public static Object readObjectUsingDeserializationContext(
final JsonParser jp,
final DeserializationContext deserializationContext,
final JavaType javaType
) throws IOException
{
if (jp.currentToken() == JsonToken.VALUE_NULL) {
return null;
}
return deserializationContext.readValue(jp, javaType);
}

Expand Down

0 comments on commit 98ea5bb

Please sign in to comment.