如何解决如何从pojo生成数组对象并在Java中传递formparams
我需要从Pojo生成密钥为customerContactList[0].customerContactId
。我已经尝试过使用arrayList,但是我能够以下面的格式customerContactList=[{ customerContactId=2 } ]
生成,这似乎对API请求无效。
- 此Post API接受表单数据
- 如果我传入键值对
formParams.put("customerContactList[0].customerContactId",2);
,则认为它是有效的。但是我需要通过Pojo生成相同的格式。
解决方法
您的标准pojo应该看起来像这样。
{
"customerContactList": [
{
"customerContactId": 2
},{
"customerContactId": 3
}
]
}
也许这会对您有所帮助。
class Pojo {
List<CustomerContact> customerContactList;
}
class CustomerContact {
int customerContactId;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。