Lucee 7.1.0.204 - converting a number to a string

var dataRec = [
‘action’: “ping”
, ‘identifier’: “#identifier#”
, ‘msPastEpoch’: “#moment.msPastEpoch#”
];

The msPastEpoch key/value part is coming out with a type of number but I am enclosing it with a string during the creation process. Lucee should honor my datatype as the downstream process which is Google requires that value to be a string.

image

OS: Windows 11
Java Version: Java 25.0.4
Jetty Version: 12.1.12
Lucee Version: 7.1.0.204

the workaround is this:

, ‘msPastEpoch’: moment.msPastEpoch.toString()

But Lucee should honor the quotes around the value if possible

Enclosing a single value in #...# does not make it a string — in Lucee or ACF. Proof:

nbr = 123.456 + 0; // force a number nbr2 = "#nbr#";
writeOutput(getMetadata(nbr).name); // java.lang.Double
writeOutput(getMetadata(nbr2).name); // java.lang.Double <-- both engines

A quoted string that is only a single interpolation returns the inner value with its original type intact. As soon as there’s any other character in the string (a space, literal text, a second #...#), it becomes a real concatenation and you get a string. Both engines do this the same way, so it’s not a regression and not a Lucee/ACF difference.

2 Likes

(post deleted by author)