1 回答

TA貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個(gè)贊
AddParam 方法的重載怎么樣:
AddParam(List<string>)
或者通用版本:
AddParam(List<T>)
甚至:
AddParam(Collection<T>)
我想我不太明白你在問什么,但在這個(gè)方法中,你也許可以循環(huán)遍歷這些項(xiàng)目并用它們做你已經(jīng)在做的事情。
編輯:看起來你最終需要一個(gè) json 。為此,您可以使用 Unity 的內(nèi)置序列化。首先創(chuàng)建一個(gè)表示 DTO(數(shù)據(jù)傳輸對象)的類,然后將其序列化為 json 字符串。
[Serializable]
public class CryptoFilter
{
public string action;
// other string fields
public List<string> addresses;
// other string list fields
public CryptoFilter(string action, List<string> addresses)
{
this.action = action;
this.addresses = addresses;
}
}
然后使用:
CryptoFilter cryptoFilter = new CryptoFilter(...);
string json = JsonUtility.ToJson(cryptoFilter);
編輯:作為請求的字符串到字符串字典不適用于列表。使用可序列化的類,就像我為此發(fā)布的那樣。只需將其稱為 Request 等,而不是 CryptoFilter。然后創(chuàng)建該對象并將其設(shè)置為 CryptoFilter 一次,而不是多次調(diào)用 AddParam。
- 1 回答
- 0 關(guān)注
- 119 瀏覽
添加回答
舉報(bào)