从API中,我会得到如下输出:
{
"type": "string",
"code": "string",
"addInfo2": "",
"addInfo3": "23536723462",
"addInfo4": null,
"addInfo5": null,
"arrow": "none",
"IdList": [
"2357789234"
],
"templateName": null,
"rotationDegrees": "0"
}
现在,我想通过调用以下命令将此jsonstring反序列化为Object:
$this-〉序列化器-〉反序列化($jsonLabelMappings,标签Map::类,'json');
但是我希望对象有其他键/属性名。我的对象应该看起来像这样:
{
"type": "string",
"code": "string",
"originCountry": "", /* this is the addInfo2 */
"gtin": "23536723462", /* this is the ddInfo3 */
"wildfang": null, /* this is the addInfo4 */
"arrow": "none",
"ids": [ /* this is the articleIdList */
"2357789234"
],
"templateName": null,
"rotationDegrees": "0"
}
有没有像@Serializer\DeserializeName之类的注解?或者我如何告诉我的代码来自json的keyName是其他的东西?
1条答案
按热度按时间uqxowvwt1#
因为我没有得到任何答案,这将解决我的问题与注解或一些“短”。我现在做了@飞_莫伊回答:
通过将json转换为数组应该很容易做到。在数组中循环并将键替换为新的键。这就是我要做的