Skip to content

Commit

Permalink
add xml docs for converter
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsdennis committed Jun 11, 2023
1 parent a82e681 commit 03fb89a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions JsonPatch/JsonPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,27 @@ public override int GetHashCode()
}
}

/// <summary>
/// Provides JSON conversion logic for <see cref="JsonPatch"/>.
/// </summary>
public class PatchJsonConverter : JsonConverter<JsonPatch>
{
/// <summary>Reads and converts the JSON to type <see cref="JsonPatch"/>.</summary>
/// <param name="reader">The reader.</param>
/// <param name="typeToConvert">The type to convert.</param>
/// <param name="options">An object that specifies serialization options to use.</param>
/// <returns>The converted value.</returns>
public override JsonPatch Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var operations = JsonSerializer.Deserialize<List<PatchOperation>>(ref reader, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase })!;

return new JsonPatch(operations);
}

/// <summary>Writes a specified value as JSON.</summary>
/// <param name="writer">The writer to write to.</param>
/// <param name="value">The value to convert to JSON.</param>
/// <param name="options">An object that specifies serialization options to use.</param>
public override void Write(Utf8JsonWriter writer, JsonPatch value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value.Operations);
Expand Down
4 changes: 4 additions & 0 deletions tools/ApiDocsGenerator/release-notes/rn-json-patch.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ title: JsonPatch.Net
icon: fas fa-tag
order: "8.08"
---
# [2.1.0](https://github.com/gregsdennis/json-everything/pull/472) {#release-patch-2.1.0}

[#471](https://github.com/gregsdennis/json-everything/issues/397) - Make patch json converter public to support .Net source generation. Thanks to [@pwelter34](https://github.com/pwelter34) for highlighting this use case.

# [2.0.6](https://github.com/gregsdennis/json-everything/pull/400) {#release-patch-2.0.6}

[#397](https://github.com/gregsdennis/json-everything/issues/397) - Fixed an issue where `replace` needs to check that the target location exists before proceeding with the `add` portion of its operation.
Expand Down

0 comments on commit 03fb89a

Please sign in to comment.