我有一个<div class="backgroundOverlay cShow" ng-show="isShownUser">
<div class="dropDown positionPopUp inpuBlock" id="add">
<div class="inputBlock">
<h1 class="popupTitle">{{titlePopup}}</h1>
<div>
<div class="cClearFloat cInputSpace">
<input placeholder="login" ng-model="currentUser.login">
</div>
<div class="cClearFloat cInputSpace">
<input placeholder="Vorname" ng-model="currentUser.Vorname">
</div>
<div class="cClearFloat cInputSpace">
<input placeholder="Nachname" ng-model="currentUser.Nachname">
</div>
<div class="cClearFloat cInputSpace">
<input placeholder="password" ng-model="currentUser.password">
</div>
<div class="cClearFloat cInputSpace cRadioAdmin">
<label><input type="radio" name="Admin">Ja</label>
<label><input type="radio" name="Admin">Nein</label>
<div class="cClearFloat cButtonsUser">
<button class="cButtonSpeichern" ng-click="showAlert()">Speichern</button>
<button class="cButtonAbbrechen" ng-click="isShownUser = false">Abbrechen</button>
</div>
listField的类。此字段的JSON部分类似于List<BigInteger>
。我使用以下代码进行反序列化:
"listField":"[]"
但抛出异常:
com.fasterxml.jackson.databind.JsonMappingException:无法从VALUE_STRING标记中反序列化java.util.ArrayList的实例
fasterxml.jackson 2.2.3版
你能帮帮我,我该如何解决这个问题?
答案 0 :(得分:0)
除了自定义反序列化器之外,还可以添加新的setter并忽略old。它帮助了我。
@JsonProperty("listField")
public void setListFieldAsString(String listFieldAsString) {
List<BigInteger> listFieldAsList = new ArrayList<BigInteger>();
try {
ObjectMapper objectMapper = new ObjectMapper();
listFieldAsList = objectMapper.readValue(listFieldAsString, new TypeReference<List<BigInteger>>() {});
} catch (IOException e) {
System.out.println("Error was detected!");
}
setListField(listFieldAsList);
}
@JsonIgnore
public void setListField(List<BigInteger> listField) {
this.listField = listField;
}