2011-10-26 11 views
2

Jackson @JsonIgnorePropertiesはpossibleTargetを無視せず、ownerとlemfを無視します。リストを無視できます。プロパティを無視しているジャクソンライブラリ

@JsonIgnoreProperties({"owner","lemf"," possibleTargets"}) 
@Entity 
public class Warrant extends Nameable { 

    @LazyCollection(LazyCollectionOption.FALSE) 
    @OneToMany(mappedBy ="warrant",targetEntity = com.endersys.lims.model.Target.class) 
    private List<Target> possibleTargets; 

出力:

[{"status":"SCHEDULED","startDate":1320962400000,"endDate":1320962400000,"caseId":"1","possibleTargets":[],"name":"warrant_1","description":"decription","identity":"warrant_1","version":1,"systemId":1,"active":true}] 
+0

"possibleTargets"の先頭に空白があります –

答えて

2

ジャクソンは無視fields.Iをシリアル化しようとしていたので、私はまた、問題のlazyloadを持っていましたが、私は@JsonIgnoreを使用し、解決this.Usingジャクソン1.9問題にポストrelatedを見つけてきました@JsonIgnorePropertiesはまだonetomany関係では機能しません。

+0

試した他のバージョンが1.8(以前のバージョンはこれ以上管理されていない)の場合、バグレポートを提出できますか? – StaxMan

+0

@StackMan JsonIgnorePropertiesが期待どおりに機能しないjiraの問題を投稿する – ayengin

0

ジャクソンバージョン2.4を使用すると完全に動作します。

これは、あなたが実装できる方法である。このdeveloperWork post

import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 
@JsonIgnoreProperties({"id"}) 

私はジャクソンがすべてのコードをV2.4およびライブラリが提供されています実装する例を見つけました。

関連する問題