gpt4 book ai didi

struct - 长整数正在转换为科学记数法 - ColdFusion

转载 作者:行者123 更新时间:2023-12-04 21:56:19 25 4
gpt4 key购买 nike

我试图通过一个函数传递一个结构,但其中的整数正在转换为科学记数法。

反序列化前:

{"businessUnitValidList":2003051509034372557922
, "shortMessage":"Success"
, "longMessage":"Request Completed Successfully."
, "status":20001
}

反序列化后:
 businessUnitValidList  2.00305150903E+021 

我尝试将其转换为字符串,但它仍然给我相同的输出。有任何想法吗?

注意:如果我的 businessUnitValidList 中有多个值, 数字按应有的方式显示。

编辑

这是当前的代码迭代:
<cfloop array="#businessUnitArray#" index="i">

<cfquery name="validatebusinessUnit" datasource="dbproduction">
select doctorid from survey.dbo.clientLocationMap
where clientbrandid = '#arguments.clientBrandid#'
and clientLocation = '#i#'
</cfquery>

<cfif validatebusinessUnit.recordcount gt 0>
<cfset businessUnitValidList = listAppend(businessUnitValidList,toString(validatebusinessUnit.doctorid),",")>
<cfelse>
<cfset businessUnitInValidList = listAppend(businessUnitInValidList,i,",")>
</cfif>

</cfloop>

<cfif businessUnitInValidList neq ''>
<cfset ResponseStruct['BusinessUnitCodes']['businessUnitMixResponse']['businessUnitInValidList'] = "#businessUnitInValidList#">
<cfset ResponseStruct['BusinessUnitCodes']['businessUnitMixResponse']['businessUnitValidList'] = "#businessUnitValidList#">
<cfreturn serializeJSON(ResponseStruct['BusinessUnitCodes']['businessUnitMixResponse'])>
<cfelse>
<cfset ResponseStruct['BusinessUnitCodes']['businessUnitSuccess']['businessUnitValidList'] = "#businessUnitValidList#">
<cfreturn serializeJSON(ResponseStruct['BusinessUnitCodes']['businessUnitSuccess'])>
</cfif>

最佳答案

ColdFusion 的 JSON 序列化存在问题,并且可能因版本甚至修补程序而异。正如 Jedihomer Townend 在评论中提到的,前导空格应该强制 CF 将其视为字符串而不是强制转换。

我刚刚在 CF10、11 和 2016 上尝试过这个并保留了输入。

<cfscript>
a = {
"businessUnitValidList":" 2003051509034372557922",
"shortMessage":"Success",
"longMessage":"Request Completed Successfully.",
"status":20001
};
json = serializeJSON(a);
b = deserializeJSON(json);

writeDump(b);
</cfscript>

你可以在这里尝试:

http://trycf.com/gist/70b86fbb57f752125f35/acf?theme=monokai

关于struct - 长整数正在转换为科学记数法 - ColdFusion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36058910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com