FasterXML / jackson-annotations

Core annotations (annotations that only depend on jackson-core) for Jackson data processor
https://github.com/FasterXML/jackson
Apache License 2.0
1.03k stars 330 forks source link

how ignore property of property? #2

Closed ghost closed 12 years ago

ghost commented 12 years ago

i have a [personel] model like this that have [location] property i want to ignore [parent] property in Location just for this use not for all time i want to ignore [parent] property in location just in Personel model

is annotation like @ignoreproperty("perent") in property level not in class level

public class Personel extends BaseEntity  {
    private Location location;

    public Location getLocation() {
        return location;
    }
    public void setLocation(Location location) {
        this.location = location;
    }
}

public class Location extends BaseEntity{
    private String code;
    private String name;
    private Location parent;

    public Location getParent() {
        return parent;
    }

    public void setParent(Location parent) {
        this.parent = parent;
    }
}
cowtowncoder commented 12 years ago

Ok, would you indicate like this:

public class Personel extends BaseEntity  {
    @JsonIgnoreProperties({ "parent" })
    public Location location;
}

name @JsonIgnoreProperties could work, since such annotation already exists, but currently can only be used for class. But this could be changed to allow use for properties as well.

cowtowncoder commented 12 years ago

Oh. And even better, as per this Jira entry (https://jira.codehaus.org/browse/JACKSON-787), this was implemented for Jackson 2.0.0! So you can just use @JsonIgnoreProperties on fields or getter/setters. So if I understood your request correctly, this already works.

ghost commented 12 years ago

i using jackson with spring 3.1.1 but i think jackson 2 not support in this spring version plz help me how can solve my problem this is critical for me

cowtowncoder commented 12 years ago

The only solution I can think of for Jackson 1.x is to write a custom serializer.

ghost commented 12 years ago

how can do it plz help can you give me one samples plz help me

cowtowncoder commented 12 years ago

I would suggest you read a FAQ on issue trackers: these are NOT help forums, but for reporting bugs or requesting features. Help forums are different. Please subscribe to a user list or go to http://jackson-users.ning.com.

And surely you can use google to find documentation, either by yourself, or via help forums.

ghost commented 12 years ago

thanks another question how can i get just property that want not say @JsonIgnoreProperties like @JsonProperties({'id','firstname'})