0

I'm trying to find out how QuickType.io works, however I cannot find a way to show my converted results.

I converted a JSON file to C# and got a satisfactory output:

public partial class Welcome
{
    [JsonProperty("relatiesoort")]
    public string[] Relatiesoort { get; set; }

    [JsonProperty("modifiedOn")]
    public DateTimeOffset ModifiedOn { get; set; }

    [JsonProperty("relatiecode")]
    public long Relatiecode { get; set; }

    [JsonProperty("naam")]
    public string Naam { get; set; }
}

I think the Welcome class can be used to do what I want:

public partial class Welcome
{
    public static Welcome[] FromJson(string json) => JsonConvert.DeserializeObject<Welcome[]>(json, APIconnectV2.JSON.Converter.Settings);
}

This is the code I use to print the results:

var result = httpClient.GetAsync(new Uri("http://hidden.com')")).Result;
var json = result.Content.ReadAsStringAsync().Result;

dynamic jObject = JArray.Parse(json);
System.Diagnostics.Debug.WriteLine(Welcome.FromJson(json)[0]);

However, the output I receive is:

APIconnectV2.JSON.Welcome

Any number greater than 0 results in an out of bounds error. I'm not even sure if this is the correct way to print my output, however I cannot find a lot of documentation surrounding QuickType.

JavaHR
  • 173
  • 1
  • 2
  • 8
  • Can you add to your question the json you get? – OfirD Sep 06 '18 at 20:01
  • You would need to override `Welcome.ToString()` or re-serialize each `Welcome` to JSON. See [Why writing items to console writes only namespace and class name instead of data?](https://stackoverflow.com/q/43284706) and [Class List Keeps Printing Out As Class Name In Console?](https://stackoverflow.com/q/33816246) for basically identical questions. – dbc Sep 06 '18 at 21:05

0 Answers0