我正在做一个 Coldfusion 项目,我需要从 wordpress 支持的数据库中提取一些信息。我需要的一些信息位于存储在 wp_options 表中的序列化数组中。我不知道如何在 Coldfusion 中反序列化数组数据。
我目前正在使用 Coldfusion 8 的开发版本。我无法升级到 Coldfusion 9,因为我的工作应用程序是在 Coldfusion 8 上构建的,
我只能找到此链接 http://www.cfinsider.com/index.cfm/2010/5/4 /Serializing--Deserializing-in-ColdFusion-9 讨论了 CFC 的反序列化,但它似乎不适用于我传递的数组。
这是我尝试反序列化的数据的示例
a:2:{i:2;a:2:{s:5:"title";s:0:"";s:6:"number";i:5;}s:12:"_multiwidget";i:1;}
任何帮助都会很棒。
I'm working on a Coldfusion project where I need to pull some information from a wordpress powered database. Some of the information that I need is in a serialized array stored in the wp_options table. I can't figure out how to deserialize the array data in Coldfusion.
I'm currently using the dev version of Coldfusion 8. I can't upgrade to Coldfusion 9 since my works application is build on Coldfusion 8
I've only been able to find this link http://www.cfinsider.com/index.cfm/2010/5/4/Serializing--Deserializing-in-ColdFusion-9 which talks about deserializing CFC's but it doesn't seem to work on the array I'm passing.
Here is an example of the data I'm trying to deserialze
a:2:{i:2;a:2:{s:5:"title";s:0:"";s:6:"number";i:5;}s:12:"_multiwidget";i:1;}
Any help would be great.
发布评论
评论(4)
您最好的选择可能是查看 Sean Corfield 的 ColdFusion 脚本 项目。我能够用它执行以下操作:
生成:
Your best bet might be to check out Sean Corfield's scripting for ColdFusion project. I was able to do the following with it:
Which produced:
如果可以将 PHP 数组序列化为 JSON 字符串,则可以在 CF 端使用 deserializeJson。
If you can serialize the PHP array into a JSON string, you can use deserializeJson on the CF side.
嗯,这是 PHP 序列化的结果 - 我认为 CF 使用完全不同的过程。该模式看起来非常简单:
或者
这样
意味着“大小为 2 的数组 { 整数 2 ; 大小为 3 的字符串 'foo' }”。请注意,数组可以嵌套,并且对象和其他序列化类会使事情变得复杂(请参阅 PHP 序列化对象手册)。
Well, that's a result of PHP serialization - I assume CF uses a completely different process. The schema seems pretty straightforward:
or
so
would mean "array of size 2 { integer 2 ; string 'foo' of size 3 }". Note that arrays can be nested, and things can get complicated with Objects and other serialized classes (see PHP's manual on serializing objects).
我无法在任何地方找到它,所以我构建了一个解串器。
尝试一下这个要点: https://trycf.com/gist/5a795c5f52b7ad5b18ed62da8eb14f10/lucee5? theme=monokai
这是函数:
I wasn't able to find one anywhere so I've built a deserializer.
Try it in this gist: https://trycf.com/gist/5a795c5f52b7ad5b18ed62da8eb14f10/lucee5?theme=monokai
Here's the function: