[Android] Retrofit에서 null 값 받기
문제:
서버로 null 값을 넘겨 받아야 하는 상황. 통신에 문제 없고(200), 다른 값들은 잘 전달 받으나 null로 처리해야하는 부분의 기능이 먹히질 않음.
찾아보니 빈값을 null로 처리하는 과정이 필요함.
오류:
E/...: ...End of input at line 1 column 1 path $
--> null로 넘어오는 값을 따로 null 처리 해줘야함.
2022.04.26
찾아보니,,, JSON에서는 body 전체를 null로 보내면 무조건 다 error 처리하기 때문에, 바디전체가 null로 넘어온 값을 사용할 수 없는듯하다!
그래서 그냥 백엔드 개발자분께 변수 하나하나에 null 넣어서 보내달라고 요청했다......
한 4-5일을 땅만 팠다~~~ 어쨌든 곧 해결될지 확인해보자!
[참고]
https://github.com/square/retrofit/issues/1554#issuecomment-178633697
Handle Empty Body · Issue #1554 · square/retrofit
After updating to retrofit beta-3 I'm getting the Exception (Because of an empty body) java.io.EOFException: End of input at line 1 column 1 at com.google.gson.stream.JsonReader.nextNonWhitespa...
github.com
https://github.com/square/retrofit/issues/688
Posting JSON object body with a null property value · Issue #688 · square/retrofit
{"foo":{"bar":null}} I'm trying to post such json with "bar": being null; But retrofit ignores null properties in java object passed to @Body gson .serializeNulls(...
github.com
https://github.com/square/retrofit/issues/1554
Handle Empty Body · Issue #1554 · square/retrofit
After updating to retrofit beta-3 I'm getting the Exception (Because of an empty body) java.io.EOFException: End of input at line 1 column 1 at com.google.gson.stream.JsonReader.nextNonWhitespa...
github.com