Nag*_*thi 5 android rx-android retrofit2
我需要传递密钥,即使没有值,因为密钥在服务器端是必需的.但是Retrofit在发送请求时删除了具有空值的键.如何使用Retrofit将没有值的密钥发送到服务器?
请求正文如下:
{
"first_name":"testlogin",
"last_name":"lastname",
"username":"testman",
"password":"test123",
"email":"tester@test.com",
"address1":"123+test+way",
**"address2":"",**
**"address3":"",**
"postal_code":"75023",
"country":1,
**"state":""**
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
Non*_*hoi 12
尝试将其传递为:
"address2":null,
"address3":null,
"postal_code":"75023"
"country":1,
"state":null
Run Code Online (Sandbox Code Playgroud)
由于您使用的是Gson转换器,请尝试将gson创建为:
Gson gson = new GsonBuilder().serializeNulls().create();
Run Code Online (Sandbox Code Playgroud)
从这里开始.
| 归档时间: |
|
| 查看次数: |
6707 次 |
| 最近记录: |