function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
geosowgeosow 

Deserializing an object that was formatted using PHP Serialize

I am working on an integration that pushes data to Salesforce using XML as the format.  However, one of the values is serialized and I'm having the hardest time parsing it.  It is getting serialized on the other end using the PHP Serialize function.  Is there anything out there that I can use in Apex that can help deserialize this value?  Even if I have to do a callout with the value to get deserialized data back, I'd be happy with that.  Thanks,

 

~geosow

 

PS - this is an integration with Magento.

sfdcfoxsfdcfox

Don't do it, if at all possible. Stick with json_encode in PHP, it's far easier to work with in Apex Code. You could also use the XML parser, but I find that JSON is the best in Apex Code, as you can easily slip an entire object from its serialized state into a single usable object in a single line of code.

geosowgeosow

I agree with you.  However, I have no control over the source application.  I'm doing a callout and the PHP serialized value is what I get so I have to make parse it somehow and was hoping to deserialize it in Apex somehow.