をデシリアライズすることはできません。これは、json.netのウェブサイトからの例のJSONがあるC#のjson.net:
public class Account
{
public string Email { get; set; }
public bool Active { get; set; }
public DateTime CreatedDate { get; set; }
public IList<string> Roles { get; set; }
}
用法:
string json = @"{
'Email': '[email protected]',
'Active': true,
'CreatedDate': '2013-01-20T00:00:00Z',
'Roles': [
'User',
'Admin'
]
}";
Account account = JsonConvert.DeserializeObject<Account>(json);
Console.WriteLine(account.Email);
しかし、私はそれを実行すると、私はエラーを取得しています:
Unable to find a constructor to use for type Gogch.Account. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'Email', line 1, position 9.
私は別のトピックで述べたように空のコンストラクタを追加しましたが、私はまだ同じエラーが発生しています。どんな助けもありがとうございます。
*別のトピックで述べたように空のコンストラクタを追加しました*あなたは 'Account'の完全なコードを表示できますか? – Rob
あなたがここに書いたコードはうまく動作します。これはXamarinで問題が発生しているのか、それともクイックコンソールアプリで再現できるのですか? –
csharppadの作品:http://csharppad.com/gist/aab77cb2581b47e05fcc3488669537f0 –