0% found this document useful (0 votes)
526 views1 page

Finderouter

The document describes a ByteArrayHexConverter class that can convert between byte arrays and their hexadecimal string representations when serializing and deserializing JSON. The class implements the CanConvert, ReadJson, WriteJson methods of the JsonConverter interface to enable this custom conversion.

Uploaded by

MisterTeo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
526 views1 page

Finderouter

The document describes a ByteArrayHexConverter class that can convert between byte arrays and their hexadecimal string representations when serializing and deserializing JSON. The class implements the CanConvert, ReadJson, WriteJson methods of the JsonConverter interface to enable this custom conversion.

Uploaded by

MisterTeo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// The FinderOuter

// Copyright (c) 2020 Coding Enthusiast


// Distributed under the MIT software license, see the accompanying
// file LICENCE or [Link]

using [Link];
using System;

namespace Tests
{
internal class ByteArrayHexConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(byte[]);
}

public override bool CanRead => true;


public override bool CanWrite => true;

public override object ReadJson(JsonReader reader, Type objectType, object


existingValue, JsonSerializer serializer)
{
if ([Link] == [Link])
{
string hex = [Link]<string>(reader);
return [Link](hex);
}
return [Link](reader);
}

public override void WriteJson(JsonWriter writer, object value,


JsonSerializer serializer)
{
string hexString = [Link]((byte[])value);
[Link](hexString);
}
}
}

You might also like