JSON の文字列を Json.NET などでデシアライズする際、デシアライズ先のクラスを定義する必要がありますが、JSON をクラスにするって難しいですよね。
そんな難しい JSON から C# のクラスを自動生成してくれるのが、「json2csharp」です。
こんな感じの JSON のクラスを。
{"data":{"app_id":"xxxxx","type":"USER","application":"OAuth Demo","data_access_expires_at":1547777632,"expires_at":1540004400,"is_valid":true,"scopes":["email","public_profile"],"user_id":"xxxxxx"}}
こんな具合に C# のクラスを自動生成してくれます。
public class Data { public string app_id { get; set; } public string type { get; set; } public string application { get; set; } public int data_access_expires_at { get; set; } public int expires_at { get; set; } public bool is_valid { get; set; } public List<string> scopes { get; set; } public string user_id { get; set; } } public class RootObject { public Data data { get; set; } }
メチャクチャ便利でいい感じですね。