I have a simple class with the following property:
[JsonObject(MemberSerialization.OptIn)] public class Person { ... [JsonProperty(PropertyName = "Photograph"] public byte[] Photograph { get; set; } ... }
but this doesn't work when I populate the Photograph property with an image and transfer over http. This may sound like a simple question but I've yet to find a solution after looking online for hours, but, how do I serialise/deserialise a byte array in Json.NET? What attribute tags do I need, or, should I be doing this another way? Many thanks!
public static T Deserialize<T>(byte[] data) where T : class { using (var stream = new MemoryStream(data)) using (var reader = new StreamReader(stream, Encoding.UTF8)) return JsonSerializer.Create().Deserialize(reader, typeof(T)) as T; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With