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

标签 json coldfusion case-sensitive coldfusion-9

我有一个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/

相关文章:

javascript - 使用用户定义的键将 Javascript 数组转换为 JSON

php - 区分大小写仅全部小写还是全部大写?

regex - 在 Perl 中覆盖区分大小写的正则表达式

java - 修改两个不同函数的 JSON 输出

java - JAX-RS 响应对象将对象字段显示为 NULL 值

unit-testing - Coldfusion - 找不到测试箱

ColdFusion 已定义

struct - 使用 structFindKey 及其路径通过 Coldfusion 添加新节点

sublimetext2 - sublime 中多个光标的首字母大写

php - 非常小的、持久的数据结构