In the process of creating a ticketing system using JavaScript/Angular for the frontend, and sending HTTP requests with AJAX. Currently, we are including parameters in the header as shown below:
numbPass: 3
Total Price: 39
These details belong to one order with 3 passengers. Each passenger may have a different price based on their type (regular, student, military), so dividing the total among them is not an option.
At present, these variables are received in the backend like this:
Gson gson = new Gson();
WalkIn walkinRequest = gson.fromJson(req.getReader(), WalkIn.class);
My goal is to send lists of passengers, which I discovered can be done like this:
var schedule = [];
var passenger = {
type : 'student',
price' : 150,
}
schedule.push(passenger);
var passenger = {
type : 'student',
'price' : 150,
}
schedule.push(passenger);
How can I effectively handle this data in the backend using Java (placing them into passenger objects)?
Edit: It might be a bit unclear what I'm asking. Initially, I wanted to confirm if Gson can manage processing arrays from HTTP requests. If not, then I am seeking guidance on how to address this issue. A response to this question can be found in the post below.