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!
byte[]should be converted to an array, not a string.List<T>instead, or use a JsonConverter to serialize the byte[] member. It really needs to be fixed, because it should not have issues with such basic things.Convert.ToBase64String(File.ReadAllBytes(downloadPth)andConvert.FromBase64String(b64Str)