Hello, need advise on dealing with Json response from flight aware. I’ve taken the output from this endpoint → https://aeroapi.flightaware.com/aeroapi/airports/KBNA/flights/arrivals?start=6/25/2026 11:31:37 AM&end=6/26/2026 11:31:37 AM&max_pages=10
Created a model using the paste special Json as classes from visual studio.
This creates an Arrival class like below.
public class Arrival
{
public string ident { get; set; }
public string ident_icao { get; set; }
public string ident_iata { get; set; }
public string actual_runway_off { get; set; }
public string actual_runway_on { get; set; }
public string fa_flight_id { get; set; }
public string @operator { get; set; }
public string operator_icao { get; set; }
public string operator_iata { get; set; }
public string flight_number { get; set; }
public string registration { get; set; }
public object atc_ident { get; set; }
public string inbound_fa_flight_id { get; set; }
public List codeshares { get; set; }
public List codeshares_iata { get; set; }
public bool blocked { get; set; }
public bool diverted { get; set; }
public bool cancelled { get; set; }
public bool position_only { get; set; }
public Origin origin { get; set; }
public Destination destination { get; set; }
public int departure_delay { get; set; }
public int arrival_delay { get; set; }
public int filed_ete { get; set; }
public DateTime? scheduled_out { get; set; }
public DateTime? estimated_out { get; set; }
public DateTime? actual_out { get; set; }
public DateTime scheduled_off { get; set; }
public DateTime estimated_off { get; set; }
public DateTime actual_off { get; set; }
public DateTime scheduled_on { get; set; }
public DateTime estimated_on { get; set; }
public DateTime actual_on { get; set; }
public DateTime? scheduled_in { get; set; }
public DateTime? estimated_in { get; set; }
public DateTime? actual_in { get; set; }
public int progress_percent { get; set; }
public string status { get; set; }
public string aircraft_type { get; set; }
public int route_distance { get; set; }
public int? filed_airspeed { get; set; }
public int? filed_altitude { get; set; }
public string route { get; set; }
public string baggage_claim { get; set; }
public int? seats_cabin_business { get; set; }
public int? seats_cabin_coach { get; set; }
public int? seats_cabin_first { get; set; }
public string gate_origin { get; set; }
public string gate_destination { get; set; }
public string terminal_origin { get; set; }
public object terminal_destination { get; set; }
public string type { get; set; }
}
Problem is when using the same class to write back to the database I get the error below about the codeshares.
{“Message”:“The request is invalid.”,“ModelState”:{“flightArrivals_edb.codeshares”:[“Unexpected character encountered while parsing value: [. Path ‘codeshares’, line 1, position 352.”],“flightArrivals_edb”:[“JsonToken EndArray is not valid for closing JsonType Object. Path ‘’, line 1, position 353.”]}}
codeshares in AeroAPI are handled strangely as rather than a null when empty, it returns an empty array “[ ]”. This confuses the data entity model.
The model created from the database lists a string for the codeshares where the results from the API call are actually a List type.
//------------------------------------------------------------------------------
//
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
//
//------------------------------------------------------------------------------
namespace EvokeBE
{
using System;
using System.Collections.Generic;
public partial class FlightArrivals_edb
{
public int id { get; set; }
public string ident { get; set; }
public string ident_icao { get; set; }
public string ident_iata { get; set; }
public string fa_flight_id { get; set; }
public string @operator { get; set; }
public string operator_icao { get; set; }
public string operator_iata { get; set; }
public string flight_number { get; set; }
public string registration { get; set; }
public string atc_ident { get; set; }
public string inbound_fa_flight_id { get; set; }
public string codeshares { get; set; }
public string codeshares_iata { get; set; }
public Nullable<bool> blocked { get; set; }
public Nullable<bool> diverted { get; set; }
public Nullable<bool> cancelled { get; set; }
public Nullable<bool> position_only { get; set; }
public string origin { get; set; }
public string destination { get; set; }
public Nullable<int> departure_delay { get; set; }
public Nullable<int> arrival_delay { get; set; }
public Nullable<int> filed_ete { get; set; }
public Nullable<System.DateTimeOffset> scheduled_out { get; set; }
public Nullable<System.DateTimeOffset> estimated_out { get; set; }
public Nullable<System.DateTimeOffset> actual_out { get; set; }
public Nullable<System.DateTimeOffset> scheduled_off { get; set; }
public Nullable<System.DateTimeOffset> estimated_off { get; set; }
public Nullable<System.DateTimeOffset> actual_off { get; set; }
public Nullable<System.DateTimeOffset> scheduled_on { get; set; }
public Nullable<System.DateTimeOffset> estimated_on { get; set; }
public Nullable<System.DateTimeOffset> actual_on { get; set; }
public Nullable<System.DateTimeOffset> scheduled_in { get; set; }
public Nullable<System.DateTimeOffset> estimated_in { get; set; }
public Nullable<System.DateTimeOffset> actual_in { get; set; }
public Nullable<int> progress_percent { get; set; }
public string status { get; set; }
public string aircraft_type { get; set; }
public Nullable<int> route_distance { get; set; }
public Nullable<int> filed_airspeed { get; set; }
public Nullable<int> filed_altitude { get; set; }
public string route { get; set; }
public string baggage_claim { get; set; }
public string seats_cabin_business { get; set; }
public string seats_cabin_coach { get; set; }
public string seats_cabin_first { get; set; }
public string gate_origin { get; set; }
public string gate_destination { get; set; }
public string terminal_origin { get; set; }
public string terminal_destination { get; set; }
public string type { get; set; }
}
}
Any help is appreciated or if there are pre-made models for use with c# and the data entity framework any links are appreciated.
Thank you!
