I convert bitmap to string base64. Then put it in json object. But the next data after the string base64 not include and not properly close the json. But when i put comment code for the string base64, the data will include and close json properly.
This my code for android, convert signature bitmap to base64 string and put it in json object.
Bitmap bitmapSignature = inkView.getBitmap(getResources().getColor(R.color.white));
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmapSignature.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream .toByteArray();
String signature = Base64.encodeToString(byteArray, Base64.DEFAULT);
LogCustom.i(signature, "signatureOutput");
This my code for JSON Object
JSONObject rootObject = new JSONObject();
JSONArray jobUpdatesArray = new JSONArray();
JSONObject jobUpdatesObject = new JSONObject();
jobUpdatesObject.put("Name", "John");
jobUpdatesObject.put("Signature", signature);
jobUpdatesObject.put("Address", "London");
jobUpdatesObject.put("Country", "England");
jobUpdatesArray.put(jobUpdatesObject);
rootObject.put("Job", jobUpdatesArray);
The output i got is like this. (signature long string, address and country not included and not close the json object)
{"Job": [{ "Name":"John","Signature": "iVBORw0KGgoAAAANSUhEUgAABAQAAAINCAYAAACpuK0dAAAABHNCSQQSDFRVRTBx
It not close the json..But when i put comment code for signature. I got properly json.
{"Job": [{ "Name": "John","Address": "London", "Country": "England" }]}
How to put string base64 properly in JSON object ?