1

I want to be able to check if a certain field is present in my response, and in case it is not present I would like to get an exception.

is there a way to force a GSON deserialization to throw an exception when a field is not present without a custom deserialization?

1

1 Answer 1

0

Gson optional and required fields

I've done something like this in the past. Registering a TypeAdapter seems to be a decent solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.