Newtonsoft SerializeObject gives {}

When I try to serialize object to json using newtonsoft json converter then I get "{}". I am testing it on android device.
My code is

  LoginRequest objLoginRequest = new LoginRequest();
  objLoginRequest.CompName = CompName;
  objLoginRequest.Usercode = Usercode;
  objLoginRequest.Password = Password;
  objLoginRequest.DeviceToken = "test";

 string jsonRequest = JsonConvert.SerializeObject(objLoginRequest);       

Answers

  • prashantvcprashantvc USXamarin Team Xamurai

    That's rather strange! Could you share the LoginRequest code?

  • AMARMATHURAMARMATHUR USMember
     [JsonObject(MemberSerialization.OptIn)]
        public class LoginRequest
        {
            [JsonProperty]
            public string CompName { get; set; }
            [JsonProperty]
            public string Usercode { get; set; }
            [JsonProperty]
            public string Password { get; set; }
            [JsonProperty]
            public string DeviceToken { get; set; }
        }
    

    This works well in emulator but gives "{}" in Xamarin Live Player

Sign In or Register to comment.