0
我正在使用Symfony 3.3
序列化程序。此代碼:序列化爲XML(但不是JSON)時出現異常
$serialized = $this->serializer->serialize($input, "json");
回報:
{
"title": "dsd",
"description": null,
"source": null,
"tags": null,
"objectId": null,
"attributes": {
"sdffds": "sdffsdfsd",
"fsfdsfd": "sdfsdfsdf"
},
"features": [],
"lifecycleStart": null,
"lifecycleEnd": null,
"attachments": {
"20170625194534-595012dee26c8": {
"original": "favicon (1).ico",
"filename": "favicon (1).ico",
"size": "318",
"title": null,
"description": null,
"reader": null
}
}
}
Unforutnately,運行
$serialized = $this->serializer->serialize($input, "xml");
將拋出一個異常:
Uncaught PHP Exception DOMException: "Invalid Character Error" at /www/site/ui/vendor/symfony/symfony/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php line 454
我敢肯定我沒有包括任何有趣的角色。你有任何想法我是否做錯了什麼,或者它可能是一個symfony錯誤?