In a java WebServlet I am reading in a file:
[
{"firstName":"Chelsea","surname":"Ganter","dob":"29/03/2005","scoutNumber":"181812","joiningDate":"01/09/2016"},
{"firstName":"Oliver","surname":"Greenhatch","dob":"10/09/2007","scoutNumber":"268981","joiningDate":"17/07/2019"}
]
With:
String[] myJsonData = request.getParameterValues("memberList");
I have tried to find out how I can read the objects to write to the database and I just can not get it to work (e.g., How to parse a JSON and turn its values into an Array?).
When I add:
try {
JSONObject myjson = new JSONObject(myJsonData.toString());
JSONArray the_json_array = myjson.getJSONArray("profiles");
int size = the_json_array.length();
ArrayList<JSONObject> arrays = new ArrayList<JSONObject>();
for (int i = 0; i < size; i++) {
JSONObject another_json_object = the_json_array.getJSONObject(i);
System.out.println(another_json_object);
//Blah blah blah...
arrays.add(another_json_object);
}
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
I get a 404 error before the application opens.