Skip to content

Commit 9a92c28

Browse files
committed
Add JsonExtensionData to capture unmmapped JSON data
1 parent 9b16197 commit 9a92c28

19 files changed

Lines changed: 61 additions & 72 deletions

src/AwardsJson.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
2-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
32

4-
namespace Nullforce.Api.Derpibooru.JsonModels;
5-
6-
public class AwardsJson
3+
public class AwardsJson : JsonBase
74
{
85
/// <summary>
96
/// The ID of the badge this award is derived from.

src/CommentJson.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
2-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
32

4-
namespace Nullforce.Api.Derpibooru.JsonModels;
5-
6-
public class CommentJson
3+
public class CommentJson : JsonBase
74
{
85
/// <summary>
96
/// The comment's ID.

src/FilterJson.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
22

3-
namespace Nullforce.Api.Derpibooru.JsonModels;
4-
5-
public class FilterJson
3+
public class FilterJson : JsonBase
64
{
75
/// <summary>
86
/// The id of the filter.

src/ForumJson.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
22

3-
namespace Nullforce.Api.Derpibooru.JsonModels;
4-
5-
public class ForumJson
3+
public class ForumJson : JsonBase
64
{
75
/// <summary>
86
/// The forum's description.

src/GalleryJson.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
22

3-
namespace Nullforce.Api.Derpibooru.JsonModels;
4-
5-
public class GalleryJson
3+
public class GalleryJson : JsonBase
64
{
75
/// <summary>
86
/// The gallery's ID.

src/ImageJson.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
2-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
32

4-
namespace Nullforce.Api.Derpibooru.JsonModels;
5-
6-
public class ImageJson
3+
public class ImageJson : JsonBase
74
{
85
/// <summary>
96
/// The image's ID.
@@ -143,6 +140,12 @@ public class ImageJson
143140
[JsonPropertyName("sha512_hash")]
144141
public string SHA512Hash { get; set; }
145142

143+
/// <summary>
144+
/// The number of bytes the image's file contains.
145+
/// </summary>
146+
[JsonPropertyName("size")]
147+
public long Size { get; set; }
148+
146149
/// <summary>
147150
/// The current source URL of the image.
148151
/// </summary>

src/IntensitiesJson.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
22

3-
namespace Nullforce.Api.Derpibooru.JsonModels;
4-
5-
public class IntensitiesJson
3+
public class IntensitiesJson : JsonBase
64
{
75
[JsonPropertyName("ne")]
86
public double NE { get; set; }

src/InteractionJson.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
using System.Text.Json.Serialization;
2-
3-
namespace Nullforce.Api.Derpibooru.JsonModels;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
42

53
/// <summary>
64
/// The interactions of the user specified by the API key given.
7-
/// Known interation types:
5+
/// Known interaction types:
86
/// - faved: null
97
/// - voted: up, down
108
/// </summary>
11-
public class InteractionJson
9+
public class InteractionJson : JsonBase
1210
{
1311
public int Id { get; set; }
1412
[JsonPropertyName("interaction_type")]

src/JsonBase.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
2+
3+
public abstract class JsonBase
4+
{
5+
[JsonExtensionData]
6+
public IDictionary<string, JsonElement> JsonExtensionData { get; set; }
7+
}

src/LinksJson.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
using System;
2-
using System.Text.Json.Serialization;
1+
namespace Nullforce.Api.Derpibooru.JsonModels;
32

4-
namespace Nullforce.Api.Derpibooru.JsonModels;
5-
6-
public class LinksJson
3+
public class LinksJson : JsonBase
74
{
85
/// <summary>
96
/// The creation time, in UTC, of this link.

0 commit comments

Comments
 (0)