Skip to content
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

Support for sorted trees #3995

Open
wants to merge 2 commits into
base: 2.16
Choose a base branch
from

Conversation

digulla
Copy link

@digulla digulla commented Jun 18, 2023

This patch moves the factory for ObjectNode's children to the JsonNodeFactory.

Along with a new deepCopy() method in JsonNodeFactory, this allows to create sorted trees from the mapper or sort existing trees by copying them with a JsonNodeFactory where sorting is enabled.

There was a problem with TestJDKSerialization but that could be fixed very easily with just adding an interface which merges Serializable and Supplier<T>; Java then knows what to do.

…s children map. This allows to create sorted trees.
@digulla
Copy link
Author

digulla commented Jun 20, 2023

Since you implemented sorting in a different way, I'll close this one.

@digulla digulla closed this Jun 20, 2023
@cowtowncoder
Copy link
Member

Ok; I was considering accepting this too, but hadn't formed an opinion yet -- it is a valid approach too (and bit more powerful). But just for canonical JSON probably not worth pursuing at this point.

@digulla
Copy link
Author

digulla commented Jun 21, 2023

Okay, I thought this one was breaking too much. Reopened. Take your time.

@digulla digulla reopened this Jun 21, 2023
@digulla
Copy link
Author

digulla commented Jun 22, 2023

Turns out the problem with TestJDKSerialization was very simple to fix. This now starts to look promising.

@yawkat
Copy link
Member

yawkat commented Jun 26, 2023

why is JsonNodeFactory serializable?

@cowtowncoder
Copy link
Member

cowtowncoder commented Jun 26, 2023 via email

@digulla
Copy link
Author

digulla commented Jul 4, 2023

Looks like the trick doesn't work on Android.

Options left:

  • Accept this flaw if it's not an important feature for Android.
  • If it's important but not urgent, postpone the fix for Android but give it everyone else
  • If this isn't acceptable, we can try a custom serializer which knows how to restore the two common cases and fails for others
  • or a new interface which extends Serializable and implements Supplier itself and then we do two proper implementations without lambdas.

Which way do you want to go?

@yawkat
Copy link
Member

yawkat commented Jul 10, 2023

why does this not work on android?

@cowtowncoder
Copy link
Member

Looks like there is a failure for "animal-sniffer" plugin, which is used to guard against unintended changes to levels of Android SDK that jackson-databind depends on. I'll see if I can reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants