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

查看:137
本文介绍了停止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天全站免登陆