Reputation: 25
In a unmanaged C++ program have to deserialize a json read by tcp from a server.
SERVER SIDE (made in C#) :
public class DUMMY
{
public byte[] BinaryContent { get; set; }
}
... inside a http get controller ...
DUMMY d = new DUMMY();
d.BinaryContent = new byte[] { 0x00, 0x00 }; // 0x00 is a sample, in real it contains a binary file
string sd = JsonConvert.SerializeObject(d);
return sd;
CLIENT SIDE (made in C++ unmanaged) http-get read :
{ "BinaryContent" : "AAA=" }
The problem is how to deserialize it ?
How convert "AAA=" to a 0x0000 ?
2nd Examples : IF SERVER send { 0xFF, 0xFF } string received is "ERE=".
Upvotes: 0
Views: 544
Reputation: 8171
That's Base64 encoding. https://en.wikipedia.org/wiki/Base64
It's a way that can represent arbitrary bytes using only the ASCII character set.
You'll presumably want to find a library that can decode a Base64 string and give you back the bytes it represents. (Or it's possible to write that algorithm yourself, but I don't recommend it.)
Upvotes: 3