停止 ColdFusion 对我的结构/数组进行排序 [英] Stop ColdFusion from sorting my structs/arrays

查看:15
本文介绍了停止 ColdFusion 对我的结构/数组进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CF 中将数据表示为结构数组,例如:

I have data represented in CF as an array of structs e.g.:

var foo = [{key = 'bar', value = 'baz', ... }...];

此结构按顺序迭代,然后转换为另一个相关结构,如下所示:

This structure gets iterated over sequentially and then translated to another related struct which looks like:

foo2[key] = {key = 'bar', value = 'baz', ...};

然后将其发送到 SerializeJSON() 方法并发送到浏览器.问题是 foo 或 foo2 中的键的顺序是字母顺序而不是它们添加的顺序.这会导致客户端出现问题,因为此集合会再次迭代并预计会被订购.有什么建议吗?

This is then sent to the SerializeJSON() method and sent to the browser. The problem is that the order of the keys in either foo or foo2 are alphabetical instead of in the order they were added. This is causing a problem on the client side as this collection is iterated over again and is expected to be ordered. Any suggestions?

推荐答案

如果你的集合是有序的,你需要使用一个数组.

If your collection is expected to be ordered you need to use an array.

结构不保证任何顺序,不应该这样使用.

Structs don't guarantee any ordering, and shouldn't be used as such.

这篇关于停止 ColdFusion 对我的结构/数组进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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