It's too late to answer, sorry about it, for creating the below body:
{
"username": "ًRajab",
"email": "[email protected]",
"phone": "+93767626554",
"password": "123asd",
"carType": "600fdcc646bc6409ae97e2ab",
"fcmToken":"lljlkdsajfljasldfj;lsa",
"profilePhoto": "https://st.depositphotos.com/2101611/3925/v/600/depositphotos_39258143-stock-illustration-businessman-avatar-profile-picture.jpg",
"documents": {
"DL": [
{
"_id": "5fccb687c5b4260011810125",
"uriPath": "https://webfume-onionai.s3.amazonaws.com/guest/public/document/326634-beats_by_dre-wallpaper-1366x768.jpg"
}
],
"Registration": [
{
"_id": "5fccb687c5b4260011810125",
"uriPath": "https://webfume-onionai.s3.amazonaws.com/guest/public/document/326634-beats_by_dre-wallpaper-1366x768.jpg"
}
],
"Insurance":[
{
"_id": "5fccb687c5b4260011810125",
"uriPath": "https://webfume-onionai.s3.amazonaws.com/guest/public/document/326634-beats_by_dre-wallpaper-1366x768.jpg"
}
],
"CarInside":[
{
"_id": "5fccb687c5b4260011810125",
"uriPath": "https://webfume-onionai.s3.amazonaws.com/guest/public/document/326634-beats_by_dre-wallpaper-1366x768.jpg"
}
],
"CarOutside":[
{
"_id": "5fccb687c5b4260011810125",
"uriPath": "https://webfume-onionai.s3.amazonaws.com/guest/public/document/326634-beats_by_dre-wallpaper-1366x768.jpg"
}
]
}
}
You can create dynamically like the below code:
JSONObject jsonBody = new JSONObject();
try {
jsonBody.put("username", userName);
jsonBody.put("email", email);
jsonBody.put("phone", contactNumber);
jsonBody.put("password", password);
jsonBody.put("carType", carType);
jsonBody.put("fcmToken", "lljlkdsajfljasldfj;lsa");
jsonBody.put("profilePhoto", "https://st.depositphotos.com/2101611/3925/v/600/depositphotos_39258143-stock-illustration-businessman-avatar-profile-picture.jpg");
JSONObject document = new JSONObject();
try {
document.put("DL", createDocument("5fccb687c5b4260011810125", "https://st.depositphotos.com/2101611/3925/v/600/depositphotos_39258143-stock-illustration-businessman-avatar-profile-picture.jpg"));
document.put("Registration", createDocument("5fccb687c5b4260011810125", "https://st.depositphotos.com/2101611/3925/v/600/depositphotos_39258143-stock-illustration-businessman-avatar-profile-picture.jpg"));
document.put("Insurance", createDocument("5fccb687c5b4260011810125", "https://st.depositphotos.com/2101611/3925/v/600/depositphotos_39258143-stock-illustration-businessman-avatar-profile-picture.jpg"));
document.put("CarInside", createDocument("5fccb687c5b4260011810125", "https://st.depositphotos.com/2101611/3925/v/600/depositphotos_39258143-stock-illustration-businessman-avatar-profile-picture.jpg"));
document.put("CarOutside", createDocument("5fccb687c5b4260011810125", "https://st.depositphotos.com/2101611/3925/v/600/depositphotos_39258143-stock-illustration-businessman-avatar-profile-picture.jpg"));
} catch (JSONException e) {
e.printStackTrace();
}
jsonBody.put("documents", document.toString());
Log.i("MAHDI", "Hello: Mahdi: Data: " + jsonBody);
} catch (JSONException e) {
e.printStackTrace();
}
And the createDocument method code:
public JSONArray createDocument(String id, String imageUrl) {
JSONObject dlObject = new JSONObject();
try {
dlObject.put("_id", id);
dlObject.put("uriPath", imageUrl);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONArray dlArray = new JSONArray();
dlArray.put(dlObject);
return dlArray;
}