-
Notifications
You must be signed in to change notification settings - Fork 6k
Replace improper JsonNode.toString() in Jackson support #4253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace improper JsonNode.toString() in Jackson support #4253
Conversation
By the way, I'm really interested in having the fix integrated in 4.2, I can rebase my branch on |
0e114c6
to
fd244eb
Compare
Not only is it more efficient without converting to an intermediate String, using JsonNode.toString() may not even produce valid JSON according to its Javadoc (ObjectMapper.writeValueAsString() should be used).
1c63948
to
2fe64ac
Compare
When the principal of the Authentication is an object, it is not necessarily an User: it could be another implementation of UserDetails, or even a completely unrelated type. Since the type of the object is serialized as a property and used by the deserialization anyway, there's no point in enforcing a stricter type.
2fe64ac
to
10878d1
Compare
The branch has been rebased on master and adapted to the changes in #4370. |
Thanks for the PR @fpavageau! This is merged into master. If you would like to submit a PR for 4.2.x, I'd be glad to merge it |
@@ -50,10 +50,10 @@ public Set deserialize(JsonParser jp, DeserializationContext ctxt) throws IOExce | |||
Iterator<JsonNode> nodeIterator = arrayNode.iterator(); | |||
while (nodeIterator.hasNext()) { | |||
JsonNode elementNode = nodeIterator.next(); | |||
resultSet.add(mapper.readValue(elementNode.toString(), Object.class)); | |||
resultSet.add(mapper.readValue(elementNode.traverse(mapper), Object.class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... just by chance noticed this. May have been changed since then, but method mapper.treeToValue()
would perhaps be best method to use here. It does translate to very similar call so it's not a big deal either way, and code above works fine.
The pull-request addresses 2 issues:
JsonNode.toString()
to serialize a sub-tree before deserializing it using anObjectMapper
.User
.This fixes #4252.