收藏
回答

Do not know how to serialize a BigInt怎么解决?

利用云开发发送订阅消息,一直显示报错:Do not know how to serialize a BigInt,始终不知如何解决,求方法。

回答关注问题邀请回答
收藏

10 个回答

  • 太2真人
    太2真人
    2022-07-15

    试试加上以下代码防止JSON序列化报错:

    BigInt.prototype.toJSON = function () { return this.toString() };

    2022-07-15
    有用 3
    回复 1
    • 景霖
      景霖
      2023-03-13
      您好 请问这条消息加在程序的哪里呀?
      2023-03-13
      回复
  • 罖
    2022-08-31

     return JSON.parse(JSON.stringify(result))


    2022-08-31
    有用 4
    回复 1
    • 五彩斑斓
      五彩斑斓
      2023-04-18
      什么原理?
      2023-04-18
      回复
  • Colin Jiang
    Colin Jiang
    2022-05-10

    遇到相同的问题

    2022-05-10
    有用 2
    回复
  • Zy
    Zy
    2022-04-05

    我也遇到的同样的问题。但是,并不影响程序的正常运行。

    2022-04-05
    有用 2
    回复
  • less
    less
    2022-03-20
    我也是,不过可以发送成功,会进入catch
    
    
    2022-03-20
    有用 2
    回复 4
    • 党军
      党军
      发表于移动端
      2022-03-22
      try,catch本来就是可以同时执行的,catch只是把try的问题抛出而已,虽然不影响功能,总是抛出问题让人很难受,估计是bug
      2022-03-22
      回复
    • Cherish目子分
      Cherish目子分
      2022-06-01
      发送失败单个用户 Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: TypeError: Do not know how to serialize a BigInt
          at JSON.stringify (<anonymous>)
          at callback (:16404/var/runtime/node12/CallbackContext.js:31)
          at :16404/var/runtime/node12/CallbackContext.js:81
          at :16404/var/runtime/node12/Runtime.engine.js:237
          at processTicksAndRejections (:16404/appservice/internal/process/task_queues.js:97) (callId: 1654062493905-0.8351469123361661) (trace: 13:48:13 start->13:48:14 system error (Error: errCode: -504002 functions execute fail | errMsg: TypeError: Do not know how to serialize a BigInt
          at JSON.stringify (<anonymous>)
          at callback (:16404/var/runtime/node12/CallbackContext.js:31)
          at :16404/var/runtime/node12/CallbackContext.js:81
          at :16404/var/runtime/node12/Runtime.engine.js:237
          at processTicksAndRejections (:16404/appservice/internal/process/task_queues.js:97)), abort)
          at S (WASubContext.js?t=wechat&s=1654061017246&v=2.24.0:2)
          at WASubContext.js?t=wechat&s=1654061017246&v=2.24.0:2
          at WASubContext.js?t=wechat&s=1654061017246&v=2.24.0:2
          at n (WASubContext.js?t=wechat&s=1654061017246&v=2.24.0:2)
      2022-06-01
      回复
    • Cherish目子分
      Cherish目子分
      2022-06-01
      也是失败,不过可以收到通知
      2022-06-01
      回复
    • Cherish目子分
      Cherish目子分
      2022-06-01
      有时候报错,有时候不报错
      2022-06-01
      回复
  • 阖家团圆
    阖家团圆
    2022-04-05

    楼主解决了吗?我也遇到了这个问题。

    2022-04-05
    有用 1
    回复
  • 你好
    你好
    2022-03-22
    VM180 WAService.js:2 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 64945d0b-471d-42a6-ac99-0ca7a3ddba0b, cloud function service error code -504002, error message TypeError: Do not know how to serialize a BigInt
        at JSON.stringify (<anonymous>)
        at callback (:24682/var/runtime/node12/CallbackContext.js:31)
        at :24682/var/runtime/node12/CallbackContext.js:81
        at :24682/var/runtime/node12/Runtime.engine.js:237
        at processTicksAndRejections (:24682/appservice/internal/process/task_queues.js:97); at cloud.callFunction api; 
        at new e (VM180 WAService.js:26)
        at s (VM180 WAService.js:26)
        at c (VM180 WAService.js:26)
        at Function.success (VM180 WAService.js:26)
        at I (VM180 WAService.js:2)
        at VM180 WAService.js:2
        at u (VM180 WAService.js:35)
        at Function.<anonymous> (VM180 WAService.js:35)
        at I (VM180 WAService.js:2)
        at VM180 WAService.js:2(env: macOS,mp,1.05.2201240; lib: 2.14.1)
    errorReport @ VM180 WAService.js:2
    thirdErrorReport @ VM180 WAService.js:2
    (anonymous) @ VM180 WAService.js:2
    u @ VM180 WAService.js:2
    g @ VM180 WAService.js:2
    (anonymous) @ VM180 WAService.js:2
    value @ VM180 WAService.js:2
    e @ VM180 WAService.js:2
    (anonymous) @ VM180 WAService.js:2
    
    2022-03-22
    有用 1
    回复
  • 汤磊 60070
    汤磊 60070
    04-11

    https://blog.csdn.net/weixin_52426668/article/details/130122486

    解决方案如上

    04-11
    有用
    回复
  • 十
    2023-03-28

    return JSON.stringify(sendmsg.errorCode);

    会成功但是返回null

    2023-03-28
    有用
    回复
  • ℘Adǐιづ
    ℘Adǐιづ
    发表于移动端
    2022-03-20
    ffgr
    2022-03-20
    有用
    回复
登录 后发表内容