3
我使用的是Node.js module
,它返回一個值,我需要將其轉換爲字符串或64-bit integer
。 返回的值是這樣的:節點JavaScript - 十進制字符串爲整數
{ low: 214107458, high: 17825793, unsigned: true }
的文檔指出,這是一種叫做decimal string
。我不確定這意味着什麼。 我想要的值是這樣的:76561198174373186
我該如何轉換它?
這是我得到的價值模塊: https://github.com/seishun/node-steam
這是我需要轉換值發送到模塊:https://github.com/Lwatt/node-steam-userinfo/blob/master/index.js
我的代碼:
steamFriends.on('friendMsg', function(steamID, message, type) {
if(type != Steam.EChatEntryType.ChatMsg) return;
steamuserinfo.getUserInfo(steamID, function(error, data){
if(error) throw error;
var datadec = JSON.parse(JSON.stringify(data.response)); //This returns an empty array because steamID is in incorrect form.
console.log(steamID); //Output: { low: 214107458, high: 17825793, unsigned: true }
});
});
Javascript沒有64位整數。有些圖書館可能會提供幫助,例如https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/UInt64 –
十進制表示10based編號,字符串仍然是字符串。這可能是缺乏64位整數支持的黑客/解決方法,正如John已經提到的那樣。 –
我明白了。然而字符串也很好。有沒有辦法將其轉換爲一個看起來像這樣的字符串「76561198174373186」,還是應該使用該庫? – user3757605