收藏
回答

node.js 把json对象 生成URL查询字符串出错?

raw = function (args) {

  var keys = Object.keys(args);

    keys = keys.sort()

    var newArgs = {};

    keys.forEach(function (key) {

    newArgs[key] = args[key];

    });

var rawstr1 = Object.keys(newArgs)

    .map(key => `${key}=${typeof newArgs[key]=='object'?JSON.stringify(newArgs[key]):newArgs[key]}`)

    .join('&');

   return rawstr1;

  };

raw({sign_type:'RSA2',timestamp:'2024-12-08 01:15:22'})

线下,json对象正常,线上sign_type=RSA2&timestamp=2024-12-08 01:15:22 生成 sign_type=RSA2×tamp=2024-12-08 01:15:22

&times 变成 x

线下本机正常返回

run 03 /api/cardbusiness/aggregatepay/b2c/online/consumepurchase/V1?app_id=11000000000000030694&biz_content={"mer_id":"200207010683","mer_prtcl_no":"200207010683","pay_mode":"9","access_type":"9","out_trade_no":"6624120700142","decive_info":"6601","body":"御温泉-线上支付662412070014","fee_type":"001","icbc_appid":"11000000000000030694","mer_url":"https://ywqapp-44422-8-1317875567.sh.run.tcloudbase.com/cloud/postapi/gbankpayok/","orig_date_time":"2024-12-07T23:35:22","spbill_create_ip":"11.163.0.81","total_fee":"11900","notify_type":"HS","open_id":"oLHtI5I8uLo9Lcly9XdBYnUeFRaw","shop_appid":"wxc44eb4841c41970c"}&charset=UTF-8&format=json&msg_id=662412070014-001-g2whol2&sign_type=RSA2&timestamp=2024-12-08 01:15:22

最后一次编辑于  12-08
回答关注问题邀请回答
收藏

2 个回答

  • Alfred Huang
    Alfred Huang
    12-12

    url处理&的问题,&times 在 url 中就表现为了 x

    https://www.cnblogs.com/gyfluck/p/12558079.html

    12-12
    有用
    回复
  • 长沙湘蝶科技发展有限公司
    长沙湘蝶科技发展有限公司
    12-08

    12/08 02:03:50

    ywqapp-086

    run 03 /api/cardbusiness/aggregatepay/b2c/online/consumepurchase/V1?app_id=11000000000000030694&biz_content={"mer_id":"200207010683","mer_prtcl_no":"200207010683","pay_mode":9,"access_type":9,"out_trade_no":"662412080002","decive_info":"6601","body":"御温泉-线上支付662412080002","fee_type":"001","icbc_appid":"11000000000000030694","mer_url":"https://ywqapp-44422-8-1317875567.sh.run.tcloudbase.com/cloud/postapi/gbankpayok/","orig_date_time":"2024-12-08T02:03:49","spbill_create_ip":"11.163.0.87","total_fee":"11900","notify_type":"HS","open_id":"oLHtI5I8uLo9Lcly9XdBYnUeFRaw","shop_appid":"wxc44eb4841c41970c"}&charset=UTF-8&format=json&msg_id=662412080002-001-g0x7kv&sign_type=RSA2×tamp=2024-12-08 02:03:49


    12-08
    有用
    回复
登录 后发表内容