Flow designer action step Build JSON turns integer into a string

Michael Culhan1
Kilo Sage

I want to send an integer in JSON but payload builder turns it into a string.  In the action input it is specified as an integer.

 

find_real_file.png

1 ACCEPTED SOLUTION

Hi @Michael C 

unfortunately you have to take the Payload Builder as it is and in most of the cases it doesn't matter as JavaScript is not a type-safe language like Java or C++. That means under the hood, the data in variables is permanently converted to other data types.

But I would like to know what concerns do you have with it? Does the consumer have any issues with the stringified version of the number?

Kind regards
Maik

View solution in original post

5 REPLIES 5

Maik Skoddow
Tera Patron
Tera Patron

Hi @Michael C 

this is absolutely correct as for transferring over the internet the JSON has to be converted into a pure String representation. The consumer on the other side has to parse that JSON payload and cast to the target type accordingly.

Kind regards
Maik

Thanks, Maik.  I think what I am trying to do can be accomplished in a script:

var myObj = {Description: "this is a test", Enabled: 1};
JSON.stringify(myObj)

which produces

"{"Description":"this is a test","Enabled":1}"

Is it possible to do this same thing in Payload Builder?  PB seems to turn the 1 into a "1". 

Thanks for your help and once again, my apologies for the confusion on the other question.

Hi @Michael C 

unfortunately you have to take the Payload Builder as it is and in most of the cases it doesn't matter as JavaScript is not a type-safe language like Java or C++. That means under the hood, the data in variables is permanently converted to other data types.

But I would like to know what concerns do you have with it? Does the consumer have any issues with the stringified version of the number?

Kind regards
Maik

Hi Maik,

The consumer is expecting an integer value.  I checked with support and this is indeed a limitation of Payload Builder -- it stringifies all values.  Building a payload with other data types requires scripting.  Thanks a lot!