Jeet.Deir Jeet.Deir - 8 months ago 47
JSON Question

JSON Parsing Value Not Showing

So I am using
to parse my JSON, but I get wrong output for a
List of List
Values object. Here's my code:

var reader = new StreamReader(GenerateStreamFromString(decodedString));
var rootObject = JsonConvert.DeserializeObject<RootObject>(reader.ReadToEnd());

txtOut.Text = rootObject.Results.output1.value.ColumnNames[0].ToString() + " : " +

Here are the JSON Classes:

public class Value
public List<string> ColumnNames { get; set; }
public List<string> ColumnTypes { get; set; }
public List<List<string>> Values { get; set; }

public class Output1
public string type { get; set; }
public Value value { get; set; }

public class Results
public Output1 output1 { get; set; }

public class RootObject
public Results Results { get; set; }

The output should be:

Scored Probabilities for Class "BackPocket" : 0.37687685364

While I get:

Scored Probabilities for Class "BackPocket" : System.Collections.Generic.List`1[System.String]

Where have I done wrong?


P.S. Here is a sample JSON:

{"Results":{"output1":{"type":"table","value":{"ColumnNames":["Scored Probabilities for Class \"BackPocket\"","Scored Probabilities for Class \"Ear\"","Scored Probabilities for Class \"Handbag\"","Scored Probabilities for Class \"SidePocket\"","Scored Labels"],"ColumnTypes":["Double","Double","Double","Double","String"],"Values":[["0.0249993801116943","0.999469399452209","0.00426889630034566","0.00104729761369526","Ear"]]}}}}


It is a list of lists. You're currently only indexing one level deep. You need to index two levels deep.

txtOut.Text = rootObject.Results.output1.value.ColumnNames[0].ToString() + " : " +