sonendra / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

ExclusionStrategy should provide context information #274

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

User class has a password field:

class User {

  String username;

  @Strategy(deserialize=true, serialize=false)
  String password;
}

What is the expected output? What do you see instead?

fromJson() should get password
toJson() should ignore password

but ExclusionStrategy.shouldSkipField() missing context information:

public boolean shouldSkipField(FieldAttributes attrs) {
    Strategy s = attrs.getAnnotation(Strategy.class);
    if (isSerializing() && s!=null && !s.serialize)
        return false;
    return true;
}

cannot determin isSerializing() in shouldSkipField() method.

What version of the product are you using? On what operating system?

Gson-1.6

Please provide any additional information below.

Maybe provides a Context argument?

Original issue reported on code.google.com by askxuefeng@gmail.com on 30 Dec 2010 at 2:09

GoogleCodeExporter commented 9 years ago
Functionality added as part of r710.

Original comment by joel.leitch@gmail.com on 14 Feb 2011 at 10:39