3 回答

TA貢獻1827條經驗 獲得超4個贊
您可以通過將您的課程替換為以下內容來將其解析為字典Localised
:
public Dictionary<string,string> Localised { get; set; }
Newtonsoft.JSON 和 Json.NET 可以自動將這些對象解析成字典。

TA貢獻2037條經驗 獲得超6個贊
我認為它必須是簡單的東西。我曾嘗試用
public Dictionary<string, string> Localized {get; set; }
但結果為空。
對我有用的(如 Joao Paulo Amorim 所建議的那樣)是將 Localized 替換為 Dictionary,如下所示:
public class LastName
{
public Dictionary<string, string> localized { get; set; }
public PreferredLocale preferredLocale { get; set; }
}
public class FirstName
{
public Dictionary<string, string> localized { get; set; }
public PreferredLocale preferredLocale { get; set; }
}

TA貢獻1840條經驗 獲得超5個贊
為了提取值,我使用了以下內容
var data = System.IO.File.ReadAllText(<<file address>>);
var result = JsonConvert.DeserializeObject<LinkedLiteProfile>(data);
var firstName = result.firstName.localized.Values.FirstOrDefault();
- 3 回答
- 0 關注
- 177 瀏覽
添加回答
舉報