[JsonIgnore] question

Jun 30, 2008 at 2:25 AM
Hi,

I have a question about JsonIgnore attribute. I have a User object in server side looks like this:
[Serializable]
Public class User
{
   public string UserId { get; set;}
  [JsonIgnore]
   public string Passwd { get; set;}
}

It works fine when I use get from my XHR to load the user to client browser which I don't want expose password to the client side:
jsonString = JavaScriptConvert.SerializeObject<User>(user)

But when I try to create a user from client side, I do want the Passwd property pass back to server side when call:
User user = JavaScriptConvert.DeserializeObject<User>(jsonData)

Here the user.Passwd always is empty because JsonIgnore attribute althrough I set the Passwd property on javascript side.

Is there any way I can solve this in current Json.net 2.0 release? If not, can I submit this as a feature request?

Cheers

Coordinator
Aug 4, 2008 at 9:19 AM
That isn't supported. In this sort of scenario where you are doing custom logic like this I would expect you would either write JSON yourself manually or write a JsonConverter for the User class.