135 lines
3.7 KiB
Plaintext
135 lines
3.7 KiB
Plaintext
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
|
|
|
|
public class Awesomeobject
|
|
{
|
|
[JsonConstructor]
|
|
public Awesomeobject(
|
|
[JsonProperty("SomeProps1")] int someProps1,
|
|
[JsonProperty("SomeProps2")] string someProps2
|
|
)
|
|
{
|
|
this.SomeProps1 = someProps1;
|
|
this.SomeProps2 = someProps2;
|
|
}
|
|
|
|
[JsonProperty("SomeProps1")]
|
|
public int SomeProps1 { init; get; }
|
|
|
|
[JsonProperty("SomeProps2")]
|
|
public string SomeProps2 { init; get; }
|
|
}
|
|
|
|
public class Class1
|
|
{
|
|
[JsonConstructor]
|
|
public Class1(
|
|
[JsonProperty("id")] int id,
|
|
[JsonProperty("user_id")] string userId,
|
|
[JsonProperty("awesomeobject")] Awesomeobject awesomeobject,
|
|
[JsonProperty("created_at")] string createdAt,
|
|
[JsonProperty("updated_at")] string updatedAt,
|
|
[JsonProperty("users")] IReadOnlyList<User> users
|
|
)
|
|
{
|
|
this.Id = id;
|
|
this.UserId = userId;
|
|
this.Awesomeobject = awesomeobject;
|
|
this.CreatedAt = createdAt;
|
|
this.UpdatedAt = updatedAt;
|
|
this.Users = users;
|
|
}
|
|
|
|
[JsonProperty("id")]
|
|
public int Id { init; get; }
|
|
|
|
[JsonProperty("user_id")]
|
|
public string UserId { init; get; }
|
|
|
|
[JsonProperty("awesomeobject")]
|
|
public Awesomeobject Awesomeobject { init; get; }
|
|
|
|
[JsonProperty("created_at")]
|
|
public string CreatedAt { init; get; }
|
|
|
|
[JsonProperty("updated_at")]
|
|
public string UpdatedAt { init; get; }
|
|
|
|
[JsonProperty("users")]
|
|
public IReadOnlyList<User> Users { init; get; }
|
|
}
|
|
|
|
public class Class2
|
|
{
|
|
[JsonConstructor]
|
|
public Class2(
|
|
[JsonProperty("SomePropertyOfClass2")] string somePropertyOfClass2
|
|
)
|
|
{
|
|
this.SomePropertyOfClass2 = somePropertyOfClass2;
|
|
}
|
|
|
|
[JsonProperty("SomePropertyOfClass2")]
|
|
public string SomePropertyOfClass2 { init; get; }
|
|
}
|
|
|
|
public class Root
|
|
{
|
|
[JsonConstructor]
|
|
public Root(
|
|
[JsonProperty("Class1")] Class1 class1,
|
|
[JsonProperty("Class2")] Class2 class2
|
|
)
|
|
{
|
|
this.Class1 = class1;
|
|
this.Class2 = class2;
|
|
}
|
|
|
|
[JsonProperty("Class1")]
|
|
public Class1 Class1 { init; get; }
|
|
|
|
[JsonProperty("Class2")]
|
|
public Class2 Class2 { init; get; }
|
|
}
|
|
|
|
|
|
|
|
public class User
|
|
{
|
|
[JsonConstructor]
|
|
public User(
|
|
[JsonProperty("id")] string id,
|
|
[JsonProperty("name")] string name,
|
|
[JsonProperty("created_at")] string createdAt,
|
|
[JsonProperty("updated_at")] string updatedAt,
|
|
[JsonProperty("email")] string email,
|
|
[JsonProperty("testanadditionalfield")] string testanadditionalfield
|
|
)
|
|
{
|
|
this.Id = id;
|
|
this.Name = name;
|
|
this.CreatedAt = createdAt;
|
|
this.UpdatedAt = updatedAt;
|
|
this.Email = email;
|
|
this.Testanadditionalfield = testanadditionalfield;
|
|
}
|
|
|
|
[JsonProperty("id")]
|
|
public string Id { init; get; }
|
|
|
|
[JsonProperty("name")]
|
|
public string Name { init; get; }
|
|
|
|
[JsonProperty("created_at")]
|
|
public string CreatedAt { init; get; }
|
|
|
|
[JsonProperty("updated_at")]
|
|
public string UpdatedAt { init; get; }
|
|
|
|
[JsonProperty("email")]
|
|
public string Email { init; get; }
|
|
|
|
[JsonProperty("testanadditionalfield")]
|
|
public string Testanadditionalfield { init; get; }
|
|
}
|
|
|