How to avoid JsonDataException when backend returns different JSONs on different environemnts. #1707
Unanswered
usopphammer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. I'm working on application that uses 2 different backend environments - dev and stage. Both are not stable and a lot of changes are performed every week. As a result it's available to receive different responses for the same request at different environments.
For example I receive differen type of the license field on dev and stage. As a result on stage env I receive the error:
com.squareup.moshi.JsonDataException: Expected a string but was BEGIN_OBJECT at path $.license
data classes that I need to use:
on Dev
on Stage
It's not convenient to manually change the type of the field when a build for a different environment is required, especially that the field can be nullable.
I wonder how to properly manage such situation? Is it feasible somehow to ignore the JsonDataException for some fields and just return a null in this case?
Beta Was this translation helpful? Give feedback.
All reactions