當前在我們的項目中,我們有一個具有字符串描述的特定類。
此外我們有一個對象。c# - 帶有序列化對象鍵的對象作爲對象的一部分
Object Foo {
Apple: {parts: 5},
Description: theproblematicobject,
,,,,
}
說明設置爲類型字符串。因此該對象需要被序列化以被分配爲描述的值。
最後我們返回foo作爲JSONConvert.serializer(foo)。 接收後,對象foo的格式很好JSON
,但描述仍然是一個序列化的字符串。
有沒有函數的組合,我可以如何序列化有問題的對象(因此它適合字符串類型),並在請求反序列化時,它會變成一個很好格式化的json而不是。
結果:
"Name": "Friday, 21 October 2016 New...",
"Description": "{\"HoursList\":[],\"EmployeeFullname\":\"..........",
"SwipeLeftAction": null,
"SwipeLeftDescription": null,
"SwipeLeftColor": null,
"SwipeRightAction": null,
"SwipeRightDescription": null,
"SwipeRightColor": null,
"ClickAction": "uiweb/em......."
}
期望:
"Name": "Friday, 21 October 2016 New...",
"Description": {"HoursList":[],
"EmployeeFullname" : ".........."
}
"SwipeLeftAction": null,
"SwipeLeftDescription": null,
"SwipeLeftColor": null,
"SwipeRightAction": null,
"SwipeRightDescription": null,
"SwipeRightColor": null,
"ClickAction": "uiweb/em......."
}
foo.Description是String類型的(並且我們不能在不破壞其他內容的情況下更改它) –