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 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式