I tried to encode a byte array using glib2.0. After I add the encoded data to a json
object, after I send the encoded data through pubnub
client,
I got doble slashed string from json.
This is my code :
//code for encoding data
const guchar *data=inputEncodingData;
encodedData=g_base64_encode (data,datalength);
g_print("Encoded data==>%s\n",encodedData);
It produces encoded string with slashes. like this
KA4IChkAGQAAAAAAAAAAAOAO4A4uDgAAAAAAAAoAGAAmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQD//wAAwf/A/8D/AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAEA//8CAP7/BAD6/wgA9P8SAOb/JwA2/A39mP0AAAIA4P/wD939pf2w/eL87vxz
/Nn7zasAAHMKAADIlAkKGAAYAAAAAAAAAAAA4Jbgls6UAAAAAAAACgAYACYAAAAAAAAAyf+9/7//
vv/B/8D/wP+8/77/v//C/8D/vf+//8D/wP++/77/
This is the code for creating json object:
struct json_object *obj1;
obj1 = json_object_new_object();
json_object_object_add(obj1, "result", json_object_new_string(encodedData));
This will print like this:
KA4IChkAGQAAAAAAAAAAAOAO4A4uDgAAAAAAAAoAGAAmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQD\/\/wAAwf\/A\/8D\/AAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAEA\/\/8CAP7\/BAD6\/wgA9P8SAOb\/JwA2\/A39mP0AAAIA4P\/wD939
pf2w\/eL87vxz\/Nn7zasAAHMKAADIlAkKGAAYAAAAAAAAAAAA4Jbgls6UAAAAAAAACgAYACYAAA
AAAAAAyf+9\/7\/\/vv\/B\/8D\/wP+8\/77\/v\/\/C\/8D\/vf+\/\/8D\/wP++\/77\/
Why is it like this? Any idea? I need data with one slash.