1
我有以下代碼:如何序列化匿名對象到JSON,而不包括屬性名
///<summary>
///In this case you can set any other valid attribute for the editable element.
///For example, if the element is edittype:'text', we can set size, maxlength,
///etc. attributes. Refer to the valid attributes for the element
///</summary>
public object OtherOptions { get; set; }
public override string ToString()
{
return this.ToJSON();
}
我需要從OtherOptions屬性的匿名對象和序列化匿名對象的每個屬性,因爲它是從主要的對象。
如:
OtherOptions = new { A = "1", B = "2" }
如果我序列化,這將是(或像這樣):
OtherOptions: {
A: "1",
B: "2"
}
是否有可能有A和B在同一水平OtherOptions無明確地刪除它。
簡答:沒有。您將不得不與對象圖形拼合或使用自定義對象序列化。 – user2864740