# Value exceeds the limit when its converted from string to json

**URL:** https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204
**Category:** General
**Tags:** function-node
**Created:** [5 May 2023 10:44 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204 "2023-05-05T10:44:33Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)
#### Post date: [5 May 2023 10:44 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/1 "2023-05-05T10:44:33Z")

</div>

Hello,

I am getting a value from a robot (738775312330130003) but when I am converting into object I am getting the value(738775312330130000) with last two numbers as zero zero always.

I assume that its because the value is too big. Is there any way to solve it?

In the picture attached- the first output is the value from machine and the second one is when I convert into object.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/afbb92c633988d8afe66992d61653952df9b5dd2.png)

```
                                or

```

What I really want is to extract only the number out from string. What are the possibilities to do it.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 May 2023 11:01 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/2 "2023-05-05T11:01:34Z")

</div>

Yes it is too big to be held as a number. See [What is JavaScript’s highest integer value that a Number can go to without losing precision](https://www.tutorialspoint.com/what-is-javascript-s-highest-integer-value-that-a-number-can-go-to-without-losing-precision#:~:text=The%20value%20of%20the%20MAX,as%20specified%20in%20IEEE%20754).

Do you actually need it as a number or would it be ok as a string? What do you want to do with it?

If you need it as a number then you will have to use bigint, though I have never used that myself.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [5 May 2023 11:27 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/4 "2023-05-05T11:27:28Z")

</div>

Here is one example

```auto
[{"id":"474599d714e96bb9","type":"inject","z":"1d319bc3005a51a2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"status\":\"success\",\"id\":738775312330130003}","payloadType":"str","x":130,"y":280,"wires":[["4aaf250378451bf5"]]},{"id":"4aaf250378451bf5","type":"change","z":"1d319bc3005a51a2","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"(\\d+)","fromt":"re","to":"\"$1\"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":280,"wires":[["c33018984742b722"]]},{"id":"c33018984742b722","type":"json","z":"1d319bc3005a51a2","name":"","property":"payload","action":"","pretty":false,"x":370,"y":360,"wires":[["d6dd91cb9c20681f","3b64295684b6c8c2"]]},{"id":"d6dd91cb9c20681f","type":"function","z":"1d319bc3005a51a2","name":"function 29","func":"msg.payload.id = BigInt(msg.payload.id);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":360,"wires":[["3b64295684b6c8c2"]]},{"id":"3b64295684b6c8c2","type":"debug","z":"1d319bc3005a51a2","name":"debug 4 flow 3","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":280,"wires":[]}]

```

 ![chrome_screenshot_1683286205667](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/3798332a178466919caeb920d26bc73b42af38f4.png)

---

<div class="post-metadata">

### Author: ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)
#### Post date: [5 May 2023 11:27 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/5 "2023-05-05T11:27:54Z")

</div>

Hello,

I just want to get the number out from the string.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/42666500a507598d1301d2e51f8f33546ffc2ed7.png)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 May 2023 11:29 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/6 "2023-05-05T11:29:05Z")

</div>

> [@colin0031](#):
>
> I just want to get the number out from the string.

You can't because it is too big to be held in a normal number. What do you want to do with it after you have got it out?

---

<div class="post-metadata">

### Author: ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)
#### Post date: [5 May 2023 11:35 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/7 "2023-05-05T11:35:51Z")

</div>

Thanks a lot Colin.

I just wanted to display the the string as an ID in UI.

BR

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 May 2023 12:10 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/8 "2023-05-05T12:10:51Z")

</div>

Do you have control of what the robot sends? If so then change it to send a string instead of a number.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 May 2023 12:27 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/9 "2023-05-05T12:27:17Z")

</div>

To clarify that, can you make the robot return something like  
`"{"status":"success","id":"738...003"}"`

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [5 May 2023 12:48 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/10 "2023-05-05T12:48:58Z")

</div>

How are you getting the data from the robot? Is it really coming in as JSON or are you processing the incoming data to that?

---

<div class="post-metadata">

### Author: ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)
#### Post date: [10 May 2023 10:25 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/11 "2023-05-10T10:25:20Z")

</div>

Hi,

The robot is sending data in a JSON format.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [10 May 2023 10:43 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/12 "2023-05-10T10:43:53Z")

</div>

You marked an earlier post as the solution. Does that mean you have it is working ok now?

---

<div class="post-metadata">

### Author: ![colin0031](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin0031/32/85027_2.png) [@colin0031](https://discourse.nodered.org/u/colin0031)
#### Post date: [10 May 2023 10:59 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/13 "2023-05-10T10:59:04Z")

</div>

Hi,

Yes its working. Thanks a lot

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [24 May 2023 11:00 UTC](https://discourse.nodered.org/t/value-exceeds-the-limit-when-its-converted-from-string-to-json/78204/14 "2023-05-24T11:00:00Z")

</div>

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