【问题标题】:Firebase Cloud Function Data cannot be encoded BigIntFirebase Cloud Function Data 无法编码 BigInt
【发布时间】:2021-12-11 01:58:22
【问题描述】:

我专门使用 Square API,他们经常使用 bigint 类型。有没有一种简单的方法可以将此 bigint 编码为字符串?

错误:

Data cannot be encoded in JSON. 1634864610834n

【问题讨论】:

    标签: javascript node.js json typescript google-cloud-functions


    【解决方案1】:

    您可以检查BigInt 并通过将闭包作为第二个参数传递给JSON.stringify()JSON.parse() 方法来转换字符串。这是一篇包含更多信息的精彩文章。

    https://golb.hplar.ch/2018/09/javascript-bigint.html#json

    【讨论】:

      猜你喜欢
      • 2022-12-12
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      • 2020-10-26
      • 2021-03-24
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      相关资源
      最近更新 更多