Open b1conrad opened 1 year ago
This appears to be the place where the conversion to number occurs: https://github.com/Picolab/pico-engine/blob/master/packages/pico-engine-ui/src/components/PicoTabs/Testing.tsx#L21-L25
Yes, that does it.
$ node
Welcome to Node.js v16.15.0.
Type ".help" for more information.
> n="830010923977419046"
'830010923977419046'
> JSON.parse(n)
830010923977419000
> [Ctrl-D]
$
A workaround would be to enter the number into the Testing tab as "830010923977419046"
which JSON.parse
will convert into a string.
I'm lobbying for changing this behavior, removing the JSON.parse
. A KRL developer can easily apply the .decode()
operator to event attributes and function arguments, if they want incoming strings to be interpreted as Maps, Arrays, etc. The nice thing about .decode()
is that if it operates on something that already isn't a String, it just returns it unchanged.
When HTTP is used as the transport, everything is passed as a String anyway, so it make sense to let the KRL programmer .decode()
if they want to. In the case of a String of digits that is not intended as a Number, but just an identifier, the KRL programmer would not choose to .decode()
it.
When an event is raised to another pico hosted by the same pico engine, attributes are passed internally as Maps, Arrays, etc. But if the pico is on a different pico engine, http:post
is used behind the scenes so that attributes are given as Strings and will need to be decoded in that case. It's easiest to just always decode them and then it doesn't matter where the pico is hosted.
Phil reported:
Sure enough, a string of digits comes in as a number (not a quoted string).