Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deserialize PHP array in coldfusion

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.

like image 553
iangraham Avatar asked Dec 12 '22 17:12

iangraham


2 Answers

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:

alt text

like image 56
Todd Sharp Avatar answered Dec 29 '22 00:12

Todd Sharp


If you can serialize the PHP array into a JSON string, you can use deserializeJson on the CF side.

like image 22
Sean Coyne Avatar answered Dec 28 '22 23:12

Sean Coyne