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.
Your best bet might be to check out Sean Corfield's scripting for ColdFusion project. I was able to do the following with it:
<script:php>
<?php
$array = unserialize('a:2:{i:2;a:2:{s:5:"title";s:0:"";s:6:"number";i:5;}s:12:"_multiwidget";i:1;}');
$_COLDFUSION["test"] = json_encode($array);
?>
</script:php>
<cfdump var="#deserializeJSON(variables.test)#">
Which produced:
If you can serialize the PHP array into a JSON string, you can use deserializeJson on the CF side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With