Hide value in sub class during creation of JSON












0















I have one class SyncRegistrationDto which have 8 fields , and i have a subclass SyncRegistrationFailureDto (super class SyncRegistrationDto ) which have two fields only . so while returning the object of sub class also i am getting the super class variable value as a null in json data.



Super Class:



public class SyncRegistrationDto implements Serializable {

/** The Constant serialVersionUID. */
private static final long serialVersionUID = -3922338139042373367L;

/** The registration id. */
private String registrationId;

/** The sync type dto. */
private SyncTypeDto syncType;

/** The parent registration id. */
private String parentRegistrationId;

/** The sync status dto. */
private SyncStatusDto syncStatus;

/** The status comment. */
private String statusComment;

/** The lang code. */
private String langCode;

/** The is active. */
@ApiModelProperty(hidden = true)
private Boolean isActive;

/** The is deleted. */
@ApiModelProperty(hidden = true)
private Boolean isDeleted;

/**
* Instantiates a new sync registration dto.
*/
public SyncRegistrationDto() {
super();
}

/**
* Instantiates a new sync registration dto.
*
* @param registrationId
* the registration id
* @param syncTypeDto
* the sync type dto
* @param parentRegistrationId
* the parent registration id
* @param syncStatusDto
* the sync status dto
* @param statusComment
* the status comment
* @param langCode
* the lang code
*/
public SyncRegistrationDto(String registrationId, SyncTypeDto syncTypeDto, String parentRegistrationId,
SyncStatusDto syncStatusDto, String statusComment, String langCode) {
super();
this.registrationId = registrationId;
this.syncType = syncTypeDto;
this.parentRegistrationId = parentRegistrationId;
this.syncStatus = syncStatusDto;
this.statusComment = statusComment;
this.langCode = langCode;
}

/**
* Gets the registration id.
*
* @return the registration id
*/
public String getRegistrationId() {
return registrationId;
}

/**
* Sets the registration id.
*
* @param registrationId
* the new registration id
*/
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}

/**
* Gets the parent registration id.
*
* @return the parent registration id
*/
public String getParentRegistrationId() {
return parentRegistrationId;
}

/**
* Sets the parent registration id.
*
* @param parentRegistrationId
* the new parent registration id
*/
public void setParentRegistrationId(String parentRegistrationId) {
this.parentRegistrationId = parentRegistrationId;
}

/**
* Gets the status comment.
*
* @return the status comment
*/
public String getStatusComment() {
return statusComment;
}

/**
* Sets the status comment.
*
* @param statusComment
* the new status comment
*/
public void setStatusComment(String statusComment) {
this.statusComment = statusComment;
}

/**
* Gets the lang code.
*
* @return the lang code
*/
public String getLangCode() {
return langCode;
}

/**
* Sets the lang code.
*
* @param langCode
* the new lang code
*/
public void setLangCode(String langCode) {
this.langCode = langCode;
}

/**
* Gets the checks if is active.
*
* @return the checks if is active
*/
public Boolean getIsActive() {
return isActive;
}

/**
* Sets the checks if is active.
*
* @param isActive
* the new checks if is active
*/
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}

/**
* Gets the sync type dto.
*
* @return the sync type dto
*/
public SyncTypeDto getSyncType() {
return syncType;
}

/**
* Sets the sync type dto.
*
* @param syncTypeDto
* the new sync type dto
*/
public void setSyncType(SyncTypeDto syncTypeDto) {
this.syncType = syncTypeDto;
}

/**
* Gets the sync status dto.
*
* @return the sync status dto
*/
public SyncStatusDto getSyncStatus() {
return syncStatus;
}

/**
* Sets the sync status dto.
*
* @param syncStatusDto
* the new sync status dto
*/
public void setSyncStatus(SyncStatusDto syncStatusDto) {
this.syncStatus = syncStatusDto;
}

/**
* Gets the checks if is deleted.
*
* @return the checks if is deleted
*/
public Boolean getIsDeleted() {
return isDeleted;
}

/**
* Sets the checks if is deleted.
*
* @param isDeleted
* the new checks if is deleted
*/
public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}


Sub class:



public class SyncRegistrationFailureDto extends SyncRegistrationDto implements Serializable {


private static final long serialVersionUID = 4456270091048678274L;

private String registrationId;


private String messgae;

@Override
public String getRegistrationId() {
return registrationId;
}
@Override
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}


public String getMessgae() {
return messgae;
}

public void setMessgae(String messgae) {
this.messgae = messgae;
}

public SyncRegistrationFailureDto(String registrationId,String messgae) {
this.registrationId = registrationId;
this.messgae = messgae;
}


public SyncRegistrationFailureDto() {
super();
}



}


so while returning subclass object also i am getting variable of super class but i want only two value which is available in subclass how i can achieve it?



 {
"registrationId": "12345",
"syncType": null,
"parentRegistrationId": null,
"syncStatus": null,
"statusComment": null,
"langCode": null,
"isActive": null,
"isDeleted": null,
"messgae": "Not active or not valid"
}

expected o/p:

{
"registrationId": "12345",
"messgae": "Not active or not valid"
}


thanks in Advance.










share|improve this question























  • I think the question is more on why they have inheritance relationship if many of the superclass's field/method means nothing to the subclass

    – Mr. Brickowski
    Nov 28 '18 at 7:46











  • So you want ignore null fields? And What are you using to serialise the pojo to json? Swagger code-gen?

    – Ryan Carter
    Nov 28 '18 at 7:48











  • Yes Brickowski i have Inheritance because i have to return genric type of list which look like List<SyncRegistrationDto>

    – Rishabh Keshari
    Nov 28 '18 at 7:54











  • RYAN...I cant say i want to ignore null fields i want to ignore superclass fields when i am creating subclass object only.yes i am using swagger SyncRegistrationFailureDto syncRegistrationFailureDto=new SyncRegistrationFailureDto();

    – Rishabh Keshari
    Nov 28 '18 at 7:55













  • stackoverflow.com/questions/29630371/…

    – manelseo
    Nov 28 '18 at 7:57
















0















I have one class SyncRegistrationDto which have 8 fields , and i have a subclass SyncRegistrationFailureDto (super class SyncRegistrationDto ) which have two fields only . so while returning the object of sub class also i am getting the super class variable value as a null in json data.



Super Class:



public class SyncRegistrationDto implements Serializable {

/** The Constant serialVersionUID. */
private static final long serialVersionUID = -3922338139042373367L;

/** The registration id. */
private String registrationId;

/** The sync type dto. */
private SyncTypeDto syncType;

/** The parent registration id. */
private String parentRegistrationId;

/** The sync status dto. */
private SyncStatusDto syncStatus;

/** The status comment. */
private String statusComment;

/** The lang code. */
private String langCode;

/** The is active. */
@ApiModelProperty(hidden = true)
private Boolean isActive;

/** The is deleted. */
@ApiModelProperty(hidden = true)
private Boolean isDeleted;

/**
* Instantiates a new sync registration dto.
*/
public SyncRegistrationDto() {
super();
}

/**
* Instantiates a new sync registration dto.
*
* @param registrationId
* the registration id
* @param syncTypeDto
* the sync type dto
* @param parentRegistrationId
* the parent registration id
* @param syncStatusDto
* the sync status dto
* @param statusComment
* the status comment
* @param langCode
* the lang code
*/
public SyncRegistrationDto(String registrationId, SyncTypeDto syncTypeDto, String parentRegistrationId,
SyncStatusDto syncStatusDto, String statusComment, String langCode) {
super();
this.registrationId = registrationId;
this.syncType = syncTypeDto;
this.parentRegistrationId = parentRegistrationId;
this.syncStatus = syncStatusDto;
this.statusComment = statusComment;
this.langCode = langCode;
}

/**
* Gets the registration id.
*
* @return the registration id
*/
public String getRegistrationId() {
return registrationId;
}

/**
* Sets the registration id.
*
* @param registrationId
* the new registration id
*/
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}

/**
* Gets the parent registration id.
*
* @return the parent registration id
*/
public String getParentRegistrationId() {
return parentRegistrationId;
}

/**
* Sets the parent registration id.
*
* @param parentRegistrationId
* the new parent registration id
*/
public void setParentRegistrationId(String parentRegistrationId) {
this.parentRegistrationId = parentRegistrationId;
}

/**
* Gets the status comment.
*
* @return the status comment
*/
public String getStatusComment() {
return statusComment;
}

/**
* Sets the status comment.
*
* @param statusComment
* the new status comment
*/
public void setStatusComment(String statusComment) {
this.statusComment = statusComment;
}

/**
* Gets the lang code.
*
* @return the lang code
*/
public String getLangCode() {
return langCode;
}

/**
* Sets the lang code.
*
* @param langCode
* the new lang code
*/
public void setLangCode(String langCode) {
this.langCode = langCode;
}

/**
* Gets the checks if is active.
*
* @return the checks if is active
*/
public Boolean getIsActive() {
return isActive;
}

/**
* Sets the checks if is active.
*
* @param isActive
* the new checks if is active
*/
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}

/**
* Gets the sync type dto.
*
* @return the sync type dto
*/
public SyncTypeDto getSyncType() {
return syncType;
}

/**
* Sets the sync type dto.
*
* @param syncTypeDto
* the new sync type dto
*/
public void setSyncType(SyncTypeDto syncTypeDto) {
this.syncType = syncTypeDto;
}

/**
* Gets the sync status dto.
*
* @return the sync status dto
*/
public SyncStatusDto getSyncStatus() {
return syncStatus;
}

/**
* Sets the sync status dto.
*
* @param syncStatusDto
* the new sync status dto
*/
public void setSyncStatus(SyncStatusDto syncStatusDto) {
this.syncStatus = syncStatusDto;
}

/**
* Gets the checks if is deleted.
*
* @return the checks if is deleted
*/
public Boolean getIsDeleted() {
return isDeleted;
}

/**
* Sets the checks if is deleted.
*
* @param isDeleted
* the new checks if is deleted
*/
public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}


Sub class:



public class SyncRegistrationFailureDto extends SyncRegistrationDto implements Serializable {


private static final long serialVersionUID = 4456270091048678274L;

private String registrationId;


private String messgae;

@Override
public String getRegistrationId() {
return registrationId;
}
@Override
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}


public String getMessgae() {
return messgae;
}

public void setMessgae(String messgae) {
this.messgae = messgae;
}

public SyncRegistrationFailureDto(String registrationId,String messgae) {
this.registrationId = registrationId;
this.messgae = messgae;
}


public SyncRegistrationFailureDto() {
super();
}



}


so while returning subclass object also i am getting variable of super class but i want only two value which is available in subclass how i can achieve it?



 {
"registrationId": "12345",
"syncType": null,
"parentRegistrationId": null,
"syncStatus": null,
"statusComment": null,
"langCode": null,
"isActive": null,
"isDeleted": null,
"messgae": "Not active or not valid"
}

expected o/p:

{
"registrationId": "12345",
"messgae": "Not active or not valid"
}


thanks in Advance.










share|improve this question























  • I think the question is more on why they have inheritance relationship if many of the superclass's field/method means nothing to the subclass

    – Mr. Brickowski
    Nov 28 '18 at 7:46











  • So you want ignore null fields? And What are you using to serialise the pojo to json? Swagger code-gen?

    – Ryan Carter
    Nov 28 '18 at 7:48











  • Yes Brickowski i have Inheritance because i have to return genric type of list which look like List<SyncRegistrationDto>

    – Rishabh Keshari
    Nov 28 '18 at 7:54











  • RYAN...I cant say i want to ignore null fields i want to ignore superclass fields when i am creating subclass object only.yes i am using swagger SyncRegistrationFailureDto syncRegistrationFailureDto=new SyncRegistrationFailureDto();

    – Rishabh Keshari
    Nov 28 '18 at 7:55













  • stackoverflow.com/questions/29630371/…

    – manelseo
    Nov 28 '18 at 7:57














0












0








0








I have one class SyncRegistrationDto which have 8 fields , and i have a subclass SyncRegistrationFailureDto (super class SyncRegistrationDto ) which have two fields only . so while returning the object of sub class also i am getting the super class variable value as a null in json data.



Super Class:



public class SyncRegistrationDto implements Serializable {

/** The Constant serialVersionUID. */
private static final long serialVersionUID = -3922338139042373367L;

/** The registration id. */
private String registrationId;

/** The sync type dto. */
private SyncTypeDto syncType;

/** The parent registration id. */
private String parentRegistrationId;

/** The sync status dto. */
private SyncStatusDto syncStatus;

/** The status comment. */
private String statusComment;

/** The lang code. */
private String langCode;

/** The is active. */
@ApiModelProperty(hidden = true)
private Boolean isActive;

/** The is deleted. */
@ApiModelProperty(hidden = true)
private Boolean isDeleted;

/**
* Instantiates a new sync registration dto.
*/
public SyncRegistrationDto() {
super();
}

/**
* Instantiates a new sync registration dto.
*
* @param registrationId
* the registration id
* @param syncTypeDto
* the sync type dto
* @param parentRegistrationId
* the parent registration id
* @param syncStatusDto
* the sync status dto
* @param statusComment
* the status comment
* @param langCode
* the lang code
*/
public SyncRegistrationDto(String registrationId, SyncTypeDto syncTypeDto, String parentRegistrationId,
SyncStatusDto syncStatusDto, String statusComment, String langCode) {
super();
this.registrationId = registrationId;
this.syncType = syncTypeDto;
this.parentRegistrationId = parentRegistrationId;
this.syncStatus = syncStatusDto;
this.statusComment = statusComment;
this.langCode = langCode;
}

/**
* Gets the registration id.
*
* @return the registration id
*/
public String getRegistrationId() {
return registrationId;
}

/**
* Sets the registration id.
*
* @param registrationId
* the new registration id
*/
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}

/**
* Gets the parent registration id.
*
* @return the parent registration id
*/
public String getParentRegistrationId() {
return parentRegistrationId;
}

/**
* Sets the parent registration id.
*
* @param parentRegistrationId
* the new parent registration id
*/
public void setParentRegistrationId(String parentRegistrationId) {
this.parentRegistrationId = parentRegistrationId;
}

/**
* Gets the status comment.
*
* @return the status comment
*/
public String getStatusComment() {
return statusComment;
}

/**
* Sets the status comment.
*
* @param statusComment
* the new status comment
*/
public void setStatusComment(String statusComment) {
this.statusComment = statusComment;
}

/**
* Gets the lang code.
*
* @return the lang code
*/
public String getLangCode() {
return langCode;
}

/**
* Sets the lang code.
*
* @param langCode
* the new lang code
*/
public void setLangCode(String langCode) {
this.langCode = langCode;
}

/**
* Gets the checks if is active.
*
* @return the checks if is active
*/
public Boolean getIsActive() {
return isActive;
}

/**
* Sets the checks if is active.
*
* @param isActive
* the new checks if is active
*/
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}

/**
* Gets the sync type dto.
*
* @return the sync type dto
*/
public SyncTypeDto getSyncType() {
return syncType;
}

/**
* Sets the sync type dto.
*
* @param syncTypeDto
* the new sync type dto
*/
public void setSyncType(SyncTypeDto syncTypeDto) {
this.syncType = syncTypeDto;
}

/**
* Gets the sync status dto.
*
* @return the sync status dto
*/
public SyncStatusDto getSyncStatus() {
return syncStatus;
}

/**
* Sets the sync status dto.
*
* @param syncStatusDto
* the new sync status dto
*/
public void setSyncStatus(SyncStatusDto syncStatusDto) {
this.syncStatus = syncStatusDto;
}

/**
* Gets the checks if is deleted.
*
* @return the checks if is deleted
*/
public Boolean getIsDeleted() {
return isDeleted;
}

/**
* Sets the checks if is deleted.
*
* @param isDeleted
* the new checks if is deleted
*/
public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}


Sub class:



public class SyncRegistrationFailureDto extends SyncRegistrationDto implements Serializable {


private static final long serialVersionUID = 4456270091048678274L;

private String registrationId;


private String messgae;

@Override
public String getRegistrationId() {
return registrationId;
}
@Override
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}


public String getMessgae() {
return messgae;
}

public void setMessgae(String messgae) {
this.messgae = messgae;
}

public SyncRegistrationFailureDto(String registrationId,String messgae) {
this.registrationId = registrationId;
this.messgae = messgae;
}


public SyncRegistrationFailureDto() {
super();
}



}


so while returning subclass object also i am getting variable of super class but i want only two value which is available in subclass how i can achieve it?



 {
"registrationId": "12345",
"syncType": null,
"parentRegistrationId": null,
"syncStatus": null,
"statusComment": null,
"langCode": null,
"isActive": null,
"isDeleted": null,
"messgae": "Not active or not valid"
}

expected o/p:

{
"registrationId": "12345",
"messgae": "Not active or not valid"
}


thanks in Advance.










share|improve this question














I have one class SyncRegistrationDto which have 8 fields , and i have a subclass SyncRegistrationFailureDto (super class SyncRegistrationDto ) which have two fields only . so while returning the object of sub class also i am getting the super class variable value as a null in json data.



Super Class:



public class SyncRegistrationDto implements Serializable {

/** The Constant serialVersionUID. */
private static final long serialVersionUID = -3922338139042373367L;

/** The registration id. */
private String registrationId;

/** The sync type dto. */
private SyncTypeDto syncType;

/** The parent registration id. */
private String parentRegistrationId;

/** The sync status dto. */
private SyncStatusDto syncStatus;

/** The status comment. */
private String statusComment;

/** The lang code. */
private String langCode;

/** The is active. */
@ApiModelProperty(hidden = true)
private Boolean isActive;

/** The is deleted. */
@ApiModelProperty(hidden = true)
private Boolean isDeleted;

/**
* Instantiates a new sync registration dto.
*/
public SyncRegistrationDto() {
super();
}

/**
* Instantiates a new sync registration dto.
*
* @param registrationId
* the registration id
* @param syncTypeDto
* the sync type dto
* @param parentRegistrationId
* the parent registration id
* @param syncStatusDto
* the sync status dto
* @param statusComment
* the status comment
* @param langCode
* the lang code
*/
public SyncRegistrationDto(String registrationId, SyncTypeDto syncTypeDto, String parentRegistrationId,
SyncStatusDto syncStatusDto, String statusComment, String langCode) {
super();
this.registrationId = registrationId;
this.syncType = syncTypeDto;
this.parentRegistrationId = parentRegistrationId;
this.syncStatus = syncStatusDto;
this.statusComment = statusComment;
this.langCode = langCode;
}

/**
* Gets the registration id.
*
* @return the registration id
*/
public String getRegistrationId() {
return registrationId;
}

/**
* Sets the registration id.
*
* @param registrationId
* the new registration id
*/
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}

/**
* Gets the parent registration id.
*
* @return the parent registration id
*/
public String getParentRegistrationId() {
return parentRegistrationId;
}

/**
* Sets the parent registration id.
*
* @param parentRegistrationId
* the new parent registration id
*/
public void setParentRegistrationId(String parentRegistrationId) {
this.parentRegistrationId = parentRegistrationId;
}

/**
* Gets the status comment.
*
* @return the status comment
*/
public String getStatusComment() {
return statusComment;
}

/**
* Sets the status comment.
*
* @param statusComment
* the new status comment
*/
public void setStatusComment(String statusComment) {
this.statusComment = statusComment;
}

/**
* Gets the lang code.
*
* @return the lang code
*/
public String getLangCode() {
return langCode;
}

/**
* Sets the lang code.
*
* @param langCode
* the new lang code
*/
public void setLangCode(String langCode) {
this.langCode = langCode;
}

/**
* Gets the checks if is active.
*
* @return the checks if is active
*/
public Boolean getIsActive() {
return isActive;
}

/**
* Sets the checks if is active.
*
* @param isActive
* the new checks if is active
*/
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}

/**
* Gets the sync type dto.
*
* @return the sync type dto
*/
public SyncTypeDto getSyncType() {
return syncType;
}

/**
* Sets the sync type dto.
*
* @param syncTypeDto
* the new sync type dto
*/
public void setSyncType(SyncTypeDto syncTypeDto) {
this.syncType = syncTypeDto;
}

/**
* Gets the sync status dto.
*
* @return the sync status dto
*/
public SyncStatusDto getSyncStatus() {
return syncStatus;
}

/**
* Sets the sync status dto.
*
* @param syncStatusDto
* the new sync status dto
*/
public void setSyncStatus(SyncStatusDto syncStatusDto) {
this.syncStatus = syncStatusDto;
}

/**
* Gets the checks if is deleted.
*
* @return the checks if is deleted
*/
public Boolean getIsDeleted() {
return isDeleted;
}

/**
* Sets the checks if is deleted.
*
* @param isDeleted
* the new checks if is deleted
*/
public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}


Sub class:



public class SyncRegistrationFailureDto extends SyncRegistrationDto implements Serializable {


private static final long serialVersionUID = 4456270091048678274L;

private String registrationId;


private String messgae;

@Override
public String getRegistrationId() {
return registrationId;
}
@Override
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}


public String getMessgae() {
return messgae;
}

public void setMessgae(String messgae) {
this.messgae = messgae;
}

public SyncRegistrationFailureDto(String registrationId,String messgae) {
this.registrationId = registrationId;
this.messgae = messgae;
}


public SyncRegistrationFailureDto() {
super();
}



}


so while returning subclass object also i am getting variable of super class but i want only two value which is available in subclass how i can achieve it?



 {
"registrationId": "12345",
"syncType": null,
"parentRegistrationId": null,
"syncStatus": null,
"statusComment": null,
"langCode": null,
"isActive": null,
"isDeleted": null,
"messgae": "Not active or not valid"
}

expected o/p:

{
"registrationId": "12345",
"messgae": "Not active or not valid"
}


thanks in Advance.







java json rest






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 7:39









Rishabh KeshariRishabh Keshari

1




1













  • I think the question is more on why they have inheritance relationship if many of the superclass's field/method means nothing to the subclass

    – Mr. Brickowski
    Nov 28 '18 at 7:46











  • So you want ignore null fields? And What are you using to serialise the pojo to json? Swagger code-gen?

    – Ryan Carter
    Nov 28 '18 at 7:48











  • Yes Brickowski i have Inheritance because i have to return genric type of list which look like List<SyncRegistrationDto>

    – Rishabh Keshari
    Nov 28 '18 at 7:54











  • RYAN...I cant say i want to ignore null fields i want to ignore superclass fields when i am creating subclass object only.yes i am using swagger SyncRegistrationFailureDto syncRegistrationFailureDto=new SyncRegistrationFailureDto();

    – Rishabh Keshari
    Nov 28 '18 at 7:55













  • stackoverflow.com/questions/29630371/…

    – manelseo
    Nov 28 '18 at 7:57



















  • I think the question is more on why they have inheritance relationship if many of the superclass's field/method means nothing to the subclass

    – Mr. Brickowski
    Nov 28 '18 at 7:46











  • So you want ignore null fields? And What are you using to serialise the pojo to json? Swagger code-gen?

    – Ryan Carter
    Nov 28 '18 at 7:48











  • Yes Brickowski i have Inheritance because i have to return genric type of list which look like List<SyncRegistrationDto>

    – Rishabh Keshari
    Nov 28 '18 at 7:54











  • RYAN...I cant say i want to ignore null fields i want to ignore superclass fields when i am creating subclass object only.yes i am using swagger SyncRegistrationFailureDto syncRegistrationFailureDto=new SyncRegistrationFailureDto();

    – Rishabh Keshari
    Nov 28 '18 at 7:55













  • stackoverflow.com/questions/29630371/…

    – manelseo
    Nov 28 '18 at 7:57

















I think the question is more on why they have inheritance relationship if many of the superclass's field/method means nothing to the subclass

– Mr. Brickowski
Nov 28 '18 at 7:46





I think the question is more on why they have inheritance relationship if many of the superclass's field/method means nothing to the subclass

– Mr. Brickowski
Nov 28 '18 at 7:46













So you want ignore null fields? And What are you using to serialise the pojo to json? Swagger code-gen?

– Ryan Carter
Nov 28 '18 at 7:48





So you want ignore null fields? And What are you using to serialise the pojo to json? Swagger code-gen?

– Ryan Carter
Nov 28 '18 at 7:48













Yes Brickowski i have Inheritance because i have to return genric type of list which look like List<SyncRegistrationDto>

– Rishabh Keshari
Nov 28 '18 at 7:54





Yes Brickowski i have Inheritance because i have to return genric type of list which look like List<SyncRegistrationDto>

– Rishabh Keshari
Nov 28 '18 at 7:54













RYAN...I cant say i want to ignore null fields i want to ignore superclass fields when i am creating subclass object only.yes i am using swagger SyncRegistrationFailureDto syncRegistrationFailureDto=new SyncRegistrationFailureDto();

– Rishabh Keshari
Nov 28 '18 at 7:55







RYAN...I cant say i want to ignore null fields i want to ignore superclass fields when i am creating subclass object only.yes i am using swagger SyncRegistrationFailureDto syncRegistrationFailureDto=new SyncRegistrationFailureDto();

– Rishabh Keshari
Nov 28 '18 at 7:55















stackoverflow.com/questions/29630371/…

– manelseo
Nov 28 '18 at 7:57





stackoverflow.com/questions/29630371/…

– manelseo
Nov 28 '18 at 7:57












1 Answer
1






active

oldest

votes


















0














Simple solution would be to use @JsonInclude(Include.NON_NULL)






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53514401%2fhide-value-in-sub-class-during-creation-of-json%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Simple solution would be to use @JsonInclude(Include.NON_NULL)






    share|improve this answer




























      0














      Simple solution would be to use @JsonInclude(Include.NON_NULL)






      share|improve this answer


























        0












        0








        0







        Simple solution would be to use @JsonInclude(Include.NON_NULL)






        share|improve this answer













        Simple solution would be to use @JsonInclude(Include.NON_NULL)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 28 '18 at 7:55









        MicDMicD

        17918




        17918
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53514401%2fhide-value-in-sub-class-during-creation-of-json%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks