0

Hi follow up question regarding to No data displayed only brackets in web API C#

When I declare

public ChartType[] chart_type { get; set; }

it doesn't display any data

but when I used

public string chart_type { get; set; }

it will display all 5 rows.

because I can't continue to another object

public partial class ChartType
{
    [JsonProperty("name", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
    public string entity_name { get; set; }

    [JsonProperty("display_name", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
    public string entity_display_name { get; set; }

    [JsonProperty("kpi", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
    public Kpi[] Kpi { get; set; }
}

and so on.....

I'm currently using complex JSON structure for my web API, hope someone helps.

npinti
  • 51,780
  • 5
  • 72
  • 96
  • What if you try and manually convert a sample instance of `CharType` to JSON yourself? If it fails, then you know that you have an issue with the serialization of it, and you might need to come up with your own custom serializer for it. – npinti Jan 06 '20 at 07:50
  • Noted, any links for the most accurate manual convert serialization ? – Vince Neil Mapatac Pablo Jan 06 '20 at 07:56
  • You can take a look [here](https://stackoverflow.com/questions/29841503/json-serialization-deserialization-in-asp-net-core). The aim is for you to try and do manually what the API does automatically. This will make it easier to tackle any issues which arise. – npinti Jan 06 '20 at 08:06

0 Answers0