I want to send an array of files to the server, for this I convert files to base64 and send to an array. Here is how the array should look like:
"attach": [ {"filename": "preved.doc", "data": BASE64_FILE_ENCODED}, ... ] and here is how I form it:
{"attach":{"values":[]} for some strange reason, I have an array of values that I don’t need at all. Here is how I send the files to the array:
ms.setArray(uploadFiles(new FileUpload(selected.getName(), readBytesFromFile(selected.getPath())))); and here is the method:
public JSONArray uploadFiles(FileUpload fileUpload) { JSONArray array = new JSONArray(); JSONObject object = new JSONObject(); try { object.put("attach", fileUpload); } catch (JSONException e) { e.printStackTrace(); } return array; } everything seems to work as it should, well, that is, in base64 everything seems to be converted correctly, but then some strange magic happens. Maybe I am not forming the array in such a way, because I didn’t quite understand the difference between JSONArray and JsonArray, maybe I don’t use what I need. I hope for your help in solving this error.