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

Ordering of map fields #7565

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open

Ordering of map fields #7565

wants to merge 3 commits into from

Conversation

vder
Copy link
Contributor

@vder vder commented Feb 14, 2025

Describe your changes

Checklist before merge

  • Related issue ID is placed at the beginning of PR title in [brackets] (can be GH issue or Nu Jira issue)
  • Code is cleaned from temporary changes and commented out lines
  • Parts of the code that are not easy to understand are documented in the code
  • Changes are covered by automated tests
  • Showcase in dev-application.conf added to demonstrate the feature
  • Documentation added or updated
  • Added entry in Changelog.md describing the change from the perspective of a public distribution user
  • Added MigrationGuide.md entry in the appropriate subcategory if introducing a breaking change
  • Verify that PR will be squashed during merge

@vder vder force-pushed the ordering_of_map_fields branch from 6659375 to f6f8afa Compare February 14, 2025 11:51
@@ -66,7 +67,7 @@ case class ToJsonEncoder(
case a: UUID => safeString(a.toString)
case a: DisplayJson => a.asJson
case a: scala.collection.Map[_, _] => encodeMap(a.toMap)
case a: java.util.Map[_, _] => encodeMap(a.asScala.toMap)
case a: java.util.Map[_, _] => encode(ListMap(a.asScala.toList: _*))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might by not optimal. You should check what is done in implementation. Maybe there is some better approach when we assume that given map is a LinkedHashMap? Can you write a micro benchmark for that and verify the difference in times between old serialization method vs the new one?

.nodeResults("end")
.map(_.variableTyped[Map[_, _]]("mapVariable"))

result shouldBe List(Some(linkedHashMap))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it check the order? I think that the intent would be more clear if you'd compare lists instead

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.

2 participants