如何在TypeScript中解析JSON数据(类型:BigInt) [英] How to parse a JSON data (type : BigInt) in TypeScript

查看:882
本文介绍了如何在TypeScript中解析JSON数据(类型:BigInt)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的请求,但这似乎比预期的要难.我必须从JSON流中解析bigint.值是990000000069396215.在我的代码中,此值在TypeScript中声明为:id_address: bigint.但这是行不通的,该值被截断,并且不返回任何内容,例如9900000000693962100

I have a simple request but It seems to be harder than expected. I have to parse a bigint from a JSON stream. The value is 990000000069396215. In my code, this value is declared in TypeScript like this: id_address: bigint. But this is not working, the value is truncated, and return nothing like 9900000000693962100

如何在我的代码中简单地管理此bigint?

How can I simply manage this bigint in my code?

推荐答案

我想您需要做类似的事情,

I guess you need to do something like this,

export interface Address {
id_address: string;
}

然后在代码中实现该接口的地方

Then somewhere in your code where you implement this interface you need to do,

const value = BigInt(id_address);  // I am guessing that inside your class you have spread your props and you can access id_address. So inside value you will get your Big integer value.

对于BigInt,参考.

这篇关于如何在TypeScript中解析JSON数据(类型:BigInt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆