davequested
06/11/2023, 9:44 PMargs = {};
args.amount = 230*100;
writedump(serializeJSON(args));abort;
Gives the result:
{"amount":23000.0}
WTF?! Why the trailing .0?
The only solution I came up with is:
args.amount = javaCast("int", 230*100);
Is there a better way?
This is in ACF2023, in ACF2016 it worked as expected.Adam Cameron
int(args.amount)
should do the trick, and more idiomatically.
But yeah a bit odd that two ints multiplied end up being a double.davequested
06/11/2023, 10:18 PMAdam Cameron
Adam Cameron
davequested
06/11/2023, 10:20 PMAdam Cameron
Adam Cameron
seancorfield
writeoutput(serializejson({amount: 230 * 100}));
(well, 2018 is broken on trycf.com right now -- everything produces a syntax error)seancorfield
seancorfield
int(230 * 100)
produces 23000
on 11, 2016, 2021... but produces 23000.0
on 10.seancorfield
javacast("int", 230 * 100)
to get an integer in JSONdavequested
06/11/2023, 11:01 PMseancorfield
seancorfield
seancorfield
seancorfield
Mark Takata (Adobe)
06/12/2023, 1:30 AMseancorfield
serializeJSON()
behavior has been the same since at least ACF 10. I think the OP was just surprised by that long-standing behavior.Mark Takata (Adobe)
06/12/2023, 2:36 PMbkbk
06/18/2023, 10:46 AMargs.amount = int(230*100);
argsMetadata = {amount: {type: "string"}};
args.setmetadata(argsMetadata);
writedump(serializeJSON(args));
abort;