在处理json时,有一个字段是数字并且位数很长,结果被处理为科学计数法

...,"tradeId":101200111072902276000243,...

经过json.decode之后取到的tradeId是1.012001110729e+23

尝试各种方法之后只能通过字符串替换解决,利用正则表达式

if not (string.find(str, '"tradeId"') == nil) then
  str=string.gsub(str, '("tradeId":)(%d+)', '%1"%2"')
end

相关文章:

  • 2022-02-28
  • 2021-09-26
  • 2021-10-12
  • 2021-12-28
  • 2021-12-14
  • 2021-08-02
  • 2021-12-01
  • 2021-06-28
猜你喜欢
  • 2021-10-26
  • 2021-06-06
  • 2021-09-01
  • 2021-07-18
  • 2021-12-29
  • 2021-11-10
  • 2021-11-05
相关资源
相似解决方案