I have a problem with converting JSON object to bytes. I need something like:
aJsonObject = new JSONObject();
// ...put somethin
string msg;
msg = aJsonObject.toString();
count = msg.countBytes(); //calculate how many bytes will string `msg` take
THEN I need to convert count to 2-element byte array (actually I need to send 16bit int to socket), convert msg to count-element byte array, link them together and send to TCP socket.
The most compliacted for me is to make count placed on exactly 16 bits.
Exactly same thing I need to do in reverse. Take 2 bytes, make them int, then read int-bytes from socket and eventually convert them to json.
I will be grateful for any help. Thanks in advance.