JObject j = JObject.Parse(\"{\'responseArray\':\'AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA\'}\");
byte[] r = j[\"responseArray\"].ToObject(JsonSerializer.C
The problem is that JObject
has already parsed the AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA
as a string
(j["responseArray"].Type
== JTokenType.String
), so the j["responseArray"].ToObject
isn't doing a de-base64.
You have to parse it directly to a byte[]
, like:
public class MyObject
{
public byte[] responseArray { get; set; }
}
MyObject cl = JsonConvert.DeserializeObject("{'responseArray':'AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA'}");
Clearly you can do the Convert.FromBase64String
"manually":
JObject j = JObject.Parse("{'responseArray':'AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA'}");
byte[] r = Convert.FromBase64String((string)j["responseArray"]);