c# - JsonConvert serialization returns "{}" -


i've got problem in following tojson() method returns string "{}"

public class genericrequest             {                 public enum supportedcommands                 {                     register, login, logout                 }                  private supportedcommands command;                 private string authentication;                 private string password;                 private string email;                  public genericrequest(supportedcommands comm, string aut, string pass, string mail)                 {                     command = comm;                     authentication = aut;                     password = pass;                     email = mail;                 }                  virtual public string tojson()                 {                     return jsonconvert.serializeobject(this);                 }     } 

got idea why serialization command doesn't serialize class's members?

the fields private; try using public properties instead (or wrapping fields in public properties).


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -