ColdFusion SerializeJSON和deSerializeJSON正在将字符串转换为数字 [英] Coldfusion SerializeJSON and deSerializeJSON is converting a string to number

查看:549
本文介绍了ColdFusion SerializeJSON和deSerializeJSON正在将字符串转换为数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ColdFusion在通过SerializeJSON和deSerializeJSON传递给JS时将字符串转换为数字。

ColdFusion is converting a string to number when passing to JS via a SerializeJSON and deSerializeJSON.

这只是在两组之间使用E数字。像3E6,65E3,56e45等。这是cfscript中的代码。

This is only happening when an 'E' is used between two set of numbers. like 3E6, 65E3, 56e45 etc. This is the code inside cfscript.

x = "2e9";
writedump(SerializeJSON(x));
writedump(deSerializeJSON(SerializeJSON(x)));

Output:
2.0E9 2000000000 

推荐答案

这是: https://bugbase.adobe.com/index.cfm?event=bug&id=3695627 :SerializeJSON会将看起来像科学的字符串符号浮动。

It is this: https://bugbase.adobe.com/index.cfm?event=bug&id=3695627: "SerializeJSON turns strings that look like scientific notation into floats."

这是CF9中的已知错误,已在CF10中修复。

It's a known bug in CF9, and it's fixed in CF10.

同时,你只需要用一些东西来填充字符串,以强制ColdFusion看不到它作为科学记数法中的数字。

In the meantime, you will just have to pad the string with something to force ColdFusion to not see it as a number in scientific notation.

或升级到CF10生命下个月,btw)。或到Railo。

Or upgrade to CF10 (CF9 is end of life next month, btw). Or to Railo.

这篇关于ColdFusion SerializeJSON和deSerializeJSON正在将字符串转换为数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆