# Last 4 numbers are being changed by BigInt method

**URL:** <https://community.postman.com/t/last-4-numbers-are-being-changed-by-bigint-method/49255>\
**Category:** Help Hub\
**Tags:** json\
**Created:** [July 5, 2023, 2:45pm UTC](https://community.postman.com/t/last-4-numbers-are-being-changed-by-bigint-method/49255 "2023-07-05T14:45:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![G-Laser](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@G-Laser](https://community.postman.com/u/G-Laser)\
**Post date:** [July 5, 2023, 2:45pm UTC](https://community.postman.com/t/last-4-numbers-are-being-changed-by-bigint-method/49255/1 "2023-07-05T14:45:58Z")

</div>

Hey,

We’ve got a REST call that returns two id’s.  
“id”: {  
“id1”: 8682604121359729092,  
“id2”: -4624766493329595303  
},  
These are quite big and so when my tests were failing I noticed that the last three digits were being changed to zeros (Example: 8682604121359729000 instead of 8682604121359729092).  
After some searching and saw that the value needed to be converted to a BigInt so, at first I used console.log(BigInt(8682604121359729092)) but that returned 8682604121359728640. In this case, the last 4 digits have been changed again but it still isn’t correct. Another suggestion was to use BigInt.asIntN(64, 8682604121359729092) but postman throws the error…  
**TypeError: Cannot convert 8682604121359729000 to a BigInt**. As you can see, the value in the error also has the replaced zeros.  
Although the values look right in the Response Body, if I send the response to the console, those values also show zeros on the end.

Any help would be appreciated since I need these id’s to run other tests.

---

<div class="post-metadata">

**Author:** ![G-Laser](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@G-Laser](https://community.postman.com/u/G-Laser)\
**Post date:** [July 7, 2023, 2:42pm UTC](https://community.postman.com/t/last-4-numbers-are-being-changed-by-bigint-method/49255/2 "2023-07-07T14:42:14Z")

</div>

I found a solution that resolved the issue. I just stringified the results of the JSON and pulled out those values using regex—extra steps but the best solution I could find.

UPDATE: I found this code online that provides the “fix”. I hope they can fix the pm.response.json() in Postman so it doesn’t zero out the numbers \> 56 bits.

> let jsonStr = pm.response.text();
> 
> const regex = “(":)(-?[0-9.]+)”;
> 
> const matches = jsonStr.matchAll(regex);
> 
> for(const match of matches){
> 
> jsonStr = jsonStr.replace(match[0], “":"” + match[2] + “"”);
> 
> }
> 
> var jsonData = JSON.parse(jsonStr);

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [July 23, 2024, 10:20pm UTC](https://community.postman.com/t/last-4-numbers-are-being-changed-by-bigint-method/49255/3 "2024-07-23T22:20:01Z")

</div>

Closed on July 23, 2024, 10:20pm UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
