所以我有以下物件初始值設定項。這適用于我也嘗試發送資料的 API。
Dim request = New With {
.data = New With {
.workspace = workspace,
.name = "Complex task test",
.notes = "These are task notes",
.projects = {"1202219487026592"},
.custom_fields = New With {
.21234515112 = "222"
}
}
}
問題是 custom_fields 需要 GID,它們是數字。顯然,我們不能為此使用數字,因此會導致問題。
有沒有辦法解決?另一種宣告這一點并獲得相同結果的方法?
uj5u.com熱心網友回復:
使用 aDictionary(Of UInt64, String)會起作用,假設您希望將custom_fields屬性值序列化為 JSON 物件:
Dim request = New With {
.data = New With {
.workspace = workspace,
.name = "Complex task test",
.notes = "These are task notes",
.projects = {"1202219487026592"},
.custom_fields = New Dictionary(Of UInt64, String) From {
{ 21234515112, "222" }
}
}
}
Dim serializedJson = JsonConvert.SerializeObject(request)
小提琴:https ://dotnetfiddle.net/NHrNqC
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/473628.html
