为什么SerializeJSON返回带有.0的int?

eri*_*old 2 coldfusion json

以下代码:

<cfscript>
struct = StructNew();
struct.x = 1;
struct.y = 2;
</cfscript>

<cfoutput>#SerializeJSON(struct)#</cfoutput>
Run Code Online (Sandbox Code Playgroud)

结果如下:

{"Y":2.0,"X":1.0}
Run Code Online (Sandbox Code Playgroud)

所以我的问题是为什么.0要添加?有没有办法删除它?

小智 5

我发现删除.0的最好的东西是使用Coldfusion函数javaCast进行强制转换:

struct.x = javaCast("int",1);
Run Code Online (Sandbox Code Playgroud)