如何从Java的请求主体中删除空节点/数组?
这是我在Java的要求,我从Pojo那里得到了。
我已经使用@jsoninclude(value = jsoninclude.include.non_null)
in phonenumber,country,电子邮件,地址,地址类。但这不是删除节点。
如何删除Phonenumber,Country,Email,地址节点/阵列?
{
"phoneNumbers": [
{
}
],
"country": {
},
"addresses": [
{
}
],
"email": [
{
"type": "primary",
"value": "[email protected]"
}
],
"password": "p@s$w0rD"
}
我希望我的请求主体如下:
{
"email": [
{
"type": "primary",
"value": "[email protected]"
}
],
"password": "p@s$w0rD"
}
这将是一个动态 post 请求,因此我正在寻找动态解决方案,不想硬编码Phonenumber,Country Country等节点。
This is my request body in java, I am getting this from POJO.
I've used @JsonInclude(value = JsonInclude.Include.NON_NULL)
in phonenumber, country, email, addresses class. But It is not removing the node.
How can I remove phonenumber, country, email, addresses nodes/arrays?
{
"phoneNumbers": [
{
}
],
"country": {
},
"addresses": [
{
}
],
"email": [
{
"type": "primary",
"value": "[email protected]"
}
],
"password": "p@s$w0rD"
}
I want my request body to be sent as below:
{
"email": [
{
"type": "primary",
"value": "[email protected]"
}
],
"password": "p@s$w0rD"
}
This would be a dynamic POST request, so I am looking for a dynamic solution, do not want to hardcode the phonenumber, country etc nodes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论