Skip to content

Commit

Permalink
refactor: JacksonSupport添加treeToValue和valueToTree
Browse files Browse the repository at this point in the history
  • Loading branch information
livk-cloud committed Jan 30, 2024
1 parent 230bac1 commit 891aef7
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public <T> T readValue(Object obj, JavaType type) {
if (obj instanceof JsonParser jsonParser) {
return mapper.readValue(jsonParser, type);
}
if (obj instanceof JsonNode jsonNode) {
return mapper.treeToValue(jsonNode, type);
}
else if (obj instanceof File file) {
return mapper.readValue(file, type);
}
Expand Down Expand Up @@ -121,7 +124,7 @@ else if (obj instanceof InputStream inputStream) {
else if (obj instanceof byte[] bytes) {
return mapper.readTree(bytes);
}
throw new UnsupportedOperationException();
return mapper.valueToTree(obj);
}

@Override
Expand Down

0 comments on commit 891aef7

Please sign in to comment.