0

Body 传参时,有没有必要将查询参数用一个字段包起来

 6 months ago
source link: https://www.v2ex.com/t/1023889
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

Body 传参时,有没有必要将查询参数用一个字段包起来

  unt · 11 小时 19 分钟前 · 1778 次点击

例如: POST /api/client

1. Body 参数
{
  pageIndex:1,
  pageSize:10,
  area:123,
  type:1,
  star:1
}
2. Body 参数
{
  pageIndex:1,
  pageSize:10,
  pBody:{
    area:1,
    type:1,
    star:1
  }
}

哪种方式比较好,我知道都可以,只是习惯问题,但是应该是有一些历史遗留原因或者道理的,可能是语言间的开发差异导致,可能是开发人员的习惯导致,可能是由。。。。。。。

请问 V 友们你们更倾向于哪种方式,原因是什么


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK