我有一个基于Jhipster的应用程序,它有一个实体demand
:
export interface IDemand {
idDemand?: number;
idSubject?: number;
demandCode?: string;
searchProfileType?: ISearchProfileDomainBean;
具有最后一个不需要的属性的下拉列表:
<select class="form-control" id="field_idProfile" name="profileType" [(ngModel)]="demand.searchProfileType">
<option [ngValue]="demand.searchProfileType == null"></option>
<option [ngValue]="profileTypeOption.id === demand.searchProfileType?.id ? demand.searchProfileType : profileTypeOption"
*ngFor="let profileTypeOption of searchProfileList; trackBy: trackProfileTypeById">{{profileTypeOption.tag}}</option>
</select>
jackson:
serialization:
indent-output: true
package com.onboarding.domain;
import java.io.Serializable;
public class SearchProfileDomainBean implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String tag;
public SearchProfileDomainBean() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
}
package com.onboarding.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
public class Demand implements Serializable {
private Long idDemand;
private Long idSubject;
private String demandCode;
private SearchProfileDomainBean searchProfileType;
private String description;
private Boolean flagCustomDemand;
private String customDemand;
private Double amount;
private String currencyCode;
private String demandState;
private Date startValidityDate;
private Date endValidityDate;
private String insertingUser;
private String lastUpdateUser;
public Demand() {
}
public Demand(Long idDemand, Long idSubject, String demandCode,
SearchProfileDomainBean searchProfileType,
String description,
Boolean flagCustomDemand, String customDemand, Double amount, String currencyCode,
String demandState, Date startValidityDate, Date endValidityDate,
String insertingUser, String lastUpdateUser) {
this.idDemand = idDemand;
this.idSubject = idSubject;
this.demandCode = demandCode;
this.searchProfileType = searchProfileType;
this.description = description;
this.flagCustomDemand = flagCustomDemand;
this.customDemand = customDemand;
this.amount = amount;
this.currencyCode = currencyCode;
this.demandState = demandState;
this.startValidityDate = startValidityDate;
this.endValidityDate = endValidityDate;
this.insertingUser = insertingUser;
this.lastUpdateUser = lastUpdateUser;
}
public Long getIdDemand() {
return idDemand;
}
public void setIdDemand(Long idDemand) {
this.idDemand = idDemand;
}
public Long getIdSubject() {
return idSubject;
}
public void setIdSubject(Long idSubject) {
this.idSubject = idSubject;
}
public String getDemandCode() {
return demandCode;
}
public void setDemandCode(String demandCode) {
this.demandCode = demandCode;
}
public Boolean getFlagCustomDemand() {
return flagCustomDemand;
}
public void setFlagCustomDemand(Boolean flagCustomDemand) {
this.flagCustomDemand = flagCustomDemand;
}
public String getCustomDemand() {
return customDemand;
}
public void setCustomDemand(String customDemand) {
this.customDemand = customDemand;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public String getCurrencyCode() {
return currencyCode;
}
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
public String getDemandState() {
return demandState;
}
public void setDemandState(String demandState) {
this.demandState = demandState;
}
public Date getStartValidityDate() {
return startValidityDate;
}
public void setStartValidityDate(Date startValidityDate) {
this.startValidityDate = startValidityDate;
}
public Date getEndValidityDate() {
return endValidityDate;
}
public void setEndValidityDate(Date endValidityDate) {
this.endValidityDate = endValidityDate;
}
public String getInsertingUser() {
return insertingUser;
}
public void setInsertingUser(String insertingUser) {
this.insertingUser = insertingUser;
}
public String getLastUpdateUser() {
return lastUpdateUser;
}
public void setLastUpdateUser(String lastUpdateUser) {
this.lastUpdateUser = lastUpdateUser;
}
public SearchProfileDomainBean getSearchProfileType() {
return searchProfileType;
}
public void setSearchProfileType(SearchProfileDomainBean searchProfileType) {
this.searchProfileType = searchProfileType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Demand demand = (Demand) o;
return Objects.equals(idDemand, demand.idDemand) &&
Objects.equals(idSubject, demand.idSubject) &&
Objects.equals(demandCode, demand.demandCode);
}
@Override
public int hashCode() {
return Objects.hash(idDemand, idSubject, demandCode);
}
}
由于一些项目限制,我修改了原来的Jhipster JPA实体。该错误是在调用create或update之后、登陆DemandResource.java之前引发的:
create(demand: IDemand): Observable<EntityResponseType> {
const copy = this.convertDateFromClient(demand);
return this.http
.post<IDemand>(this.resourceUrl, copy, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
update(demand: IDemand): Observable<EntityResponseType> {
const copy = this.convertDateFromClient(demand);
console.log('#### SERVICE demand.profileType.id = [' + demand.searchProfileType.id + ']');
console.log('#### SERVICE demand.profileType.tag = [' + demand.searchProfileType.tag + ']');
return this.http
.put<IDemand>(this.resourceUrl, copy, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
问题是您试图序列化一个布尔值,而不是一个对象。这应该起作用:
<select class="form-control" id="field_idProfile" name="profileType" [(ngModel)]="demand.searchProfileType">
<option [ngValue]="null"></option>
<option [ngValue]="profileTypeOption.id === demand.searchProfileType?.id ? demand.searchProfileType : profileTypeOption"
*ngFor="let profileTypeOption of searchProfileList; trackBy: trackProfileTypeById">{{profileTypeOption.tag}}</option>
</select>
问题内容: 我正在尝试使用Jackson将json数据转换为POJO对象。这是MainActivity和我的POJO类代码。我基本上收到了JsonMappingException错误。我还附上了整个日志。 MainActivity.java: Entries.java(这是POJO) 现在,我的日志中出现以下错误。因此,我无法继续工作。这是日志: 问题答案: 在 条目* 和 电话中 删除构造函数
代码试图采用java.awt.color类使用jackson对象映射器对其进行序列化。获取生成的json字符串并将其反序列化回java.awt.color类。但是在进行反序列化时会出现以下错误。 线程"main"com.fasterxml.jackson.databind.JsonMappingException中的异常:找不到适合类型[简单类型,类java.awt.颜色]的构造函数:无法从JSO
我正在阅读Facebook的洞察,并试图让Jackson将JSON映射到Object。如果所有的数据都不是空的,我就会让它正常工作。但是我在尝试反序列化键值的空数组时遇到了问题。即使尝试了这篇文章:如何防止Map内部的null值和bean内部的null字段通过Jackson序列化,也没有解决问题:( 这是JSON: 我的代码段如下: 全堆栈跟踪:
问题:假客户机对返回的Spring boot Rest API进行API调用时,无法反序列化该页的属性。 Spring Boot:2.3.3.发布 春云假:2.2.5.发布 com.fasterxml.jackson.databind.exc.InvalidDefinitionException:无法构造的实例(没有像默认构造函数一样的创建者存在):无法从[源:(BufferedReader);行
我在试着读我的。json文件。Is是一个车辆存储类。 这是错误: com.fasterxml.jackson.databind.exc.MismatchedInputException:无法构造的实例(尽管至少存在一个Creator):无法构造的实例(尽管至少存在一个Creator):没有字符串参数构造函数/工厂方法来从[Source:(File); line: 1,列: 1]处的字符串值反序列化