在 ColdFusion MX7 中将 JSON 字符串转换为数组 [英] Converting JSON string to an array in ColdFusion MX7

查看:13
本文介绍了在 ColdFusion MX7 中将 JSON 字符串转换为数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 cookie 值,例如:

I have a cookie value like:

"[{"index":"1","name":"TimePeriod","hidden":false},{"index":"2","name":"Enquiries","hidden":false},{"index":"3","name":"Online","hidden":false}]"

我想在 ColdFusion 中将此 cookie 值用作数组.最好的方法是什么?

I would like to use this cookie value as an array in ColdFusion. What would be the best possible way to do this?

推荐答案

正常的答案是使用内置的 deserializeJson 函数,但由于该函数在 CFMX7 中不可用(它到达 CF8),您将需要使用 UDF 来实现相同的目的.

The normal answer would be use the built-in deserializeJson function, but since that function wasn't available in CFMX7 (it arrived in CF8), you will need to use a UDF to achieve the same thing.

有两个站点包含这种类型的资源,cflib.orgriaforge.org,每个都有不同的 MX7 潜在解决方案.

There are two sites which contain resources of this type, cflib.org and riaforge.org, each of which have a different potential solution for MX7.

搜索 CFlib 提供 JsonDecode.(CFLib 对最大所需 CF 版本"有一个特定的过滤器,因此您可以确保出现的任何结果都适用于您的版本.)

Searching CFlib provides JsonDecode. (CFLib has a specific filter for "Maximum Required CF Version", so you can ensure any results that appear will work for your version.)

搜索 riaforge 提供 JSONUtil,在 MX7 上运行(但也声称比新的内置函数更好的类型映射).

Searching riaforge provides JSONUtil, which runs on MX7 (but also claims better type mapping than the newer built-in functions).

由于 MX7 在 Java 上运行,您可能还可以使用 json.org 上列出的众多 Java 库中的任何一个,使用 createObject/java.

Since MX7 runs on Java, you can likely also make use of any of the numerous Java libraries listed on json.org, using createObject/java.

这篇关于在 ColdFusion MX7 中将 JSON 字符串转换为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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