Removing PHP array deserialization in coldfusion

I am working on a Coldfusion project where I need to get some information from a wordpress-based database. Some of the information I need is a serialized array stored in the wp_options table. I cannot figure out how to deserialize array data in Coldfusion.

I am currently using the dev version of Coldfusion 8. I cannot upgrade to Coldfusion 9 since my application runs on Coldfusion 8

I managed to find this link http://www.cfinsider.com/index.cfm/2010/5/4/Serializing--Deserializing-in-ColdFusion-9 , which talks about CFC deserialization, but it doesn't seem to work to the array that I am passing.

Here is an example of the data I'm trying to execute 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
source share
3 answers

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

+4
source

Your best bet is to try out the Sean Corfield script for the ColdFusion project . I was able to do the following with him:

 <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)#"> 

What happened:

alt text

+6
source

It’s good that the result of serialization is PHP - I believe that CF uses a completely different process. The scheme seems pretty simple:

 datatype:size:structure 

or

 numbertype:numbervalue 

So

 a:2:{i:2;s:3:"foo"} 

will mean "an array of size 2 (integer 2; the string" foo "of size 3)." Note that arrays can be nested, and things can get complicated with objects and other serialized classes (see the PHP Object Serialization Guide ).

+3
source

Source: https://habr.com/ru/post/1333061/


All Articles