-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only serialize parent property if it has members
- Loading branch information
1 parent
5adf620
commit 4bb6f06
Showing
6 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Doki; | ||
|
||
internal class DocumentationObjectConverter : JsonConverter<DocumentationObject> | ||
{ | ||
public override DocumentationObject? Read(ref Utf8JsonReader reader, Type typeToConvert, | ||
JsonSerializerOptions options) | ||
{ | ||
return (DocumentationObject?)JsonSerializer.Deserialize(ref reader, typeToConvert, options); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, DocumentationObject value, JsonSerializerOptions options) | ||
{ | ||
if (!value.HasMembers) | ||
{ | ||
writer.WriteNullValue(); | ||
return; | ||
} | ||
|
||
Console.WriteLine("Writing: {0}, {1}", value.Id, writer.CurrentDepth); | ||
|
||
JsonSerializer.Serialize(writer, value, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters