JSON to Table Can't handle large floats

I am running into a problem using ‘JSON to table’ to parse large numbers. If I try to parse a number greater than 1E18 (for example 1E20, 1E30, etc.), I get an error:

ERROR JSON to Table 0:623 Execute failed: For input string: “10000000000000000000”

You can try to reproduce this by creating the workflow shown in the image below and putting the following in cell A1
{"num": 1E30}

image

I’m not sure if this is a bug or a natural limitation of KNIME. In either case, does anyone have a workaround?

Hi @joshuahoran,

The numbers parsed by the JSON to Table node are saved into a long, the maximum number presentable by a long in java is 9,223,372,036,854,775,807 which is just short of 1E19.

One workaround I found, but I am unsure if it will help you is the following: By wrapping the number in quotation marks you can force it to be interpreted as a string: {"num": "1E30"} then it can be transformed into a table without any issue.

best,
Gabriel

Thanks for the details Gabriel. It looks like the solution is to use String Replacer to modify the JSON. I will give this a try. Given that it seems unsavory to have to hack our way around valid JSON, is this worth promoting as a new feature request for the JSON node set?

Hi guys, I have the same issue regarding “trimming” the value that comes from JSON. My question is, is it possible to have this implemented or fixed in KNIME JSON to Table node?

I just made a test using JSON Path, the problem is the same. It trims the value.

Hi there!

Tnx for pointing this out. It is reported and should be taken care of. Stay tuned :wink:

Br,
Ivan

1 Like

I got the point. It is a matter of selecting the right renderer on node column. Right click over the column and select the “full precision” renderer.
This kind of useless functionality should be documented anywhere …