String approverId, String reason,String state) throws JSONException {
this.removeMyFlights(userId, flightId);
JSONArray flts = (JSONArray) myFlights.get("myflights");
Iterator<JSONObject> iter = flts.iterator();
while(iter.hasNext()) {
JSONObject flight = iter.next();
String oldFlightId = flight.getString("FlightId");
String oldUserId = flight.getString("UserId");
if(oldFlightId.equalsIgnoreCase(flightId) && oldUserId.equalsIgnoreCase(userId)) {
flts.remove(flight);
break;
}
}
JSONObject o = new JSONObject();
o.put("FlightId", flightId);
o.put("UserId", userId);
o.put("ApproverId", approverId);
o.put("Reason", reason);
o.put("state", state);
flts.put(o);
myFlights.remove("myflights");
myFlights.put("myflights", flts);
return o;