gpt4 book ai didi

json - 如何从ColdFusion中的CFC返回小写的JSON?

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

我有一个ColdFusion组件,它将返回一些JSON数据:

component
{
remote function GetPeople() returnformat="json"
{
var people = entityLoad("Person");
return people;
}
}

不幸的是,返回的JSON具有所有大写的属性名称:
[
{
FIRSTNAME: "John",
LASTNAME: "Doe"
},
{
FIRSTNAME: "Jane",
LASTNAME: "Dover
}
]

是否有任何方法可以强制框架返回JSON,以便属性名称全部为小写字母(也许是别人编写的自定义UDF/CFC)?

最佳答案

From http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_s_03.html
Note: ColdFusion internally represents structure key names using all-uppercase characters, and, therefore, serializes the key names to all-uppercase JSON representations. Any JavaScript that handles JSON representations of ColdFusion structures must use all-uppercase structure key names, such as CITY or STATE. You also use the all-uppercase names COLUMNS and DATA as the keys for the two arrays that represent ColdFusion queries in JSON format.



如果您自己定义变量,则可以使用方括号表示法(如Jason的答案所示),但是对于诸如ORM之类的内置东西,我认为您很棘手-除非您要创建自己的结构并克隆ORM版本手动将每个键的 shell 放下,但这并不是一个很好的解决方案。 :/

关于json - 如何从ColdFusion中的CFC返回小写的JSON?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7368941/

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