android - 发送键值列表对象进行改造
问题描述
我想发送这个
"question_id": 1,
"answer_id": {
"answerId1": "value1",
"answerId2": "value2"
}
通过在 android 中进行改造
我发了这个
"question_id": 1,
"answer_id": [
1,
2
]
像那样
@FormUrlEncoded
@POST(".....")
@Field("question_id") String questionId, @Field("answer_id[]") ArrayList<String> answerId)
如何对第一个请求做同样的事情?顺便说一句 HashMap<String,String> 不工作
解决方案
尝试这个
public interface myService {
@POST("/api/mypath/test")
@FormUrlEncoded
void getPositionByZip(@Query("question_id") String question_id, @FieldMap Map<String, String> answer_id);
}
// Map params need set key and value pair like
// answer_id.put("answerId1","value1");
// answer_id.put("answerId2","value2");
推荐阅读
- php - the_post_thumbnail(); 在WordPress中根据类别调用帖子时不起作用
- constraints - OBJECT IDENTIFIER 类型的子类型约束:如何将 OID 约束到某个弧?
- amazon-s3 - 需要采取的行动:S3 关闭旧版应用服务器容量
- postgresql - 布尔列上的 sqlalchemy 约束以允许具有相同外键的多行单个 true
- java - 在 jsp 页面中的 location.href 中传递当前用户名
- macos - VSCode如何折叠/展开所有子区域
- leakcanary - 此泄漏是否是由 Android 11 DP2 引起的
- r - dplyr::mutate_at 遍历函数中的列
- r - 来自不同data.frame的样本
- string - 字符串比较时间复杂度下限