{"10-29-2018":{"trip_date":"2018-10-29","dataset":{"09:30 AM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}},"07:00 PM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}}}},"10-30-2018":{"trip_date":"2018-10-30","dataset":{"09:30 AM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}},"07:00 PM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}}}},"10-31-2018":{"trip_date":"2018-10-31","dataset":{"09:30 AM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"1"},"stop_selling":{"07:00 PM":"0"}}}}}
is my original JSON
[{"trip_date":"2018-10-31","dataset":{"09:30 AM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"1"},"stop_selling":{"07:00 PM":"0"}}}},{"trip_date":"2018-10-30","dataset":{"09:30 AM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}},"07:00 PM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}}}},{"trip_date":"2018-10-29","dataset":{"09:30 AM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}},"07:00 PM":{"available_seats":"54","already_booked":0,"max_seat":"54","internal_only":{"07:00 PM":"0"},"stop_selling":{"07:00 PM":"0"}}}}]
Is what I end up after the time sort
-
$.getJSON( "/api/cx_get_tour_schedule?tour_id={tour_id}&start_date=" + start_date + "&end_date=" + end_date + "&booking_type={booking_type}", function( data ) {
alert(JSON.stringify(data['data']));
const k = Object.keys(data['data']).sort(timeSort);
new_data_array = [];
k.forEach(function (d){
item = data['data'][d];
new_data_array.push(item);
trip_date = data['data'][d].trip_date;
} )
alert(JSON.stringify(new_data_array));
sched_data = new_data_array;
Is my code
How do I add the missing property "10-29-2018":
As further down the code I have
if ( sched_data.hasOwnProperty(dte_fmt) ) {
}
where dte_frm is set to 10-20-2018 so it isn't finding anything
Thanks