0

I am trying to deserialize the following string :

{"image":"c:\testimage\test.jpg","predictions":[[0.0000103891,0.0128408,0.914102,0.0000968333,0.0729495]]}

I tested this string here and it's decoding is as I wanted. But however, C# function does not work as expected.

    public class ServerResponse
    {
        [DataMember]
        public string PredictImage { get; set; }
        [DataMember]
        public string[] JSONresult { get; set; }
    }

        private void button9_Click(object sender, EventArgs e)
        {
            string strResponse = txtJSONstring.Text;
            ServerResponse jsonResult = new ServerResponse();
            jsonResult = JsonConvert.DeserializeObject<ServerResponse>(strResponse);
            txtJSONresult.AppendText(jsonResult.PredictImage);
//            txtJSONresult.AppendText(jsonResult.JSONresult);
        }

"jsonResult" result is null always.

Any help ?

Ouroborus
  • 16,237
  • 4
  • 39
  • 62
PCG
  • 2,049
  • 5
  • 24
  • 42

1 Answers1

0

You're going to want something in this format. Your names are off and the predictions with having [[]] are a list of lists.

public class ServerResponse
{
    public string image { get; set; }
    public List<List<double>> predictions { get; set; }
}
Ryan Schlueter
  • 2,223
  • 2
  • 13
  • 19