If serialize() is the answer, you're almost certainly asking the wrong question.
JSON is widely available. The only thing it does not do, is the very thing that makes serialization immensely dangerous. All it takes is a crafty hacker to pass a crafted payload to a supposedly 'secured' serialize call, for a database driver to be overwritten with malicious code, for example.
Recreate the object. Normally. With actual data, and a source file, not with serialize. To do otherwise is laziness bordering on malice.