What am I doing wrong with JSON.NET's JsonConvert

前端 未结 4 2063
广开言路
广开言路 2021-01-27 04:56

json string

{
  \"success\": true,
  \"challenge_ts\": \"2016-11-03T17:30:00Z\",
  \"hostname\": \"mydomain.com\"
}

class

inter         


        
4条回答
  •  無奈伤痛
    2021-01-27 05:13

    Change the properties to public. By default it does not deserialize non-public properties

    internal class reCaptchaResponse
    {
        public bool success { get; set; }
        public DateTime challenge_ts { get; set; }  // timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ)
        public string hostname { get; set; }        // the hostname of the site where the reCAPTCHA was solved
        public string[] error_codes { get; set; }   // optional
    }
    

提交回复
热议问题