douyun6399 2016-10-15 16:51
浏览 24
已采纳

将值对发送到服务器

I need to send a bunch of pairs of values to a PHP server (and being "pairs", each of the two values are related), and will be using a GET request. Either of the following will work. What is the correct way to do this?

[{a:123,b:321}, {a:111,b:222}, {a:333,b:111}, {a:222,b:111}, ...]

or

[123,111,333,222] and [321,222,111,111]
  • 写回答

1条回答 默认 最新

  • donglei1699 2016-10-15 16:58
    关注

    There is not good or bad way. You just need to send data and both ways seem proper. Only advantange of second way is that it is compressed and pass lesser data through network while first one can help you to write lesser code as you can directly use json libraries.

    If data usage in not a concern then you should go with first method as it will be more convenient to handle via code.

    If the usage is from the perspective of some third person who uses the API, the it depends on how the data is related. If pair of a and b is related, then first way is preferred but if all a's are related together and b's are related separately the second way should be used.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制