- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2022 09:23 PM
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.
Solved! Go to Solution.
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2022 06:31 PM
Hi
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2022 09:27 PM
Hi
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2022 11:10 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2022 06:31 PM
Hi
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 10:53 PM
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!