Created
February 4, 2021 07:47
-
-
Save martea/f7531cf495c9c6e4235efe359246d8ce to your computer and use it in GitHub Desktop.
JsonElementConverter for newtonsoft
This file contains hidden or 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
public class JsonElementConverter : Newtonsoft.Json.JsonConverter<System.Text.Json.JsonElement> | |
{ | |
public JsonElementConverter() | |
{ | |
} | |
public override System.Text.Json.JsonElement ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, [System.Diagnostics.CodeAnalysis.AllowNull] System.Text.Json.JsonElement existingValue, bool hasExistingValue, Newtonsoft.Json.JsonSerializer serializer) | |
{ | |
throw new NotImplementedException(); | |
} | |
public override void WriteJson(Newtonsoft.Json.JsonWriter writer, [System.Diagnostics.CodeAnalysis.AllowNull] System.Text.Json.JsonElement value, Newtonsoft.Json.JsonSerializer serializer) | |
{ | |
//porting value conversion with json serializer and write it to the newtonsoft json writer. | |
writer.WriteRawValue(System.Text.Json.JsonSerializer.Serialize(value)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment