[英]localdate json binding with yasson implementation in wildfly server
[英]Do I need getters on JSON binding with Yasson?
我正在嘗試避免在POJO上使用getter和setter,但是Jersey正在使用我的getter方法將POJO轉換為JSON。
我嘗試使用Yasson,但是當我嘗試刪除自己的吸氣劑時,它只會返回空白JSON。
// the POJO
import javax.json.bind.annotation.JsonbProperty;
public final class LoginParameter {
@JsonbProperty("endpoint")
private String endPoint;
@JsonbProperty("company-id")
private String companyId;
public LoginParameter() {
endPoint = "";
companyId = "";
}
// trying to return JSON
final LoginParameter loginInfo = new LoginParameter();
loginInfo.setCompanyId("test");
loginInfo.setEndPoint("endpoint!");
return Response.status(Status.OK)
.entity(jsonb.toJson(loginInfo))
.type(MediaType.APPLICATION_JSON_TYPE).build();
默認情況下,yasson不會序列化私有成員。 為了使字段成為公共字段,或將自定義javax.json.bind.config.PropertyVisibilityStrategy
添加到運行時。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.