Skip to content

Conversation

@maximiliysiss
Copy link
Contributor

@maximiliysiss maximiliysiss commented Sep 13, 2025

Summary

This merge request introduces the WithoutStrictOrdering method to the IJsonAssertionOptions<T> interface. This method allows users to configure JSON assertions to ignore the order of elements in arrays or collections during comparison, enabling equivalency checks regardless of element sequence.

Changes

  1. Added WithoutStrictOrdering() to IJsonAssertionOptions<T>.

Motivation

The addition of WithoutStrictOrdering provides greater flexibility in JSON assertions by allowing tests to pass even when the order of array or collection elements differs between the subject and expectation.

Impact

  1. Backwards compatible change.
  2. Enables more robust and order-insensitive JSON comparisons in test scenarios.

@coveralls
Copy link

coveralls commented Sep 14, 2025

Pull Request Test Coverage Report for Build 18630461237

Details

  • 50 of 51 (98.04%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.2%) to 91.128%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Src/FluentAssertions.Json/Common/JTokenExtensions.cs 42 43 97.67%
Totals Coverage Status
Change from base Build 12815279715: 1.2%
Covered Lines: 361
Relevant Lines: 383

💛 - Coveralls

Copy link
Member

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

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

⛏️ Would be nice to add small paragraph to the readme to mention this new option

Comment on lines 12 to 14
JObject obj => new JObject(obj.Properties().OrderBy(p => p.Name).Select(p => new JProperty(p.Name, Normalize(p.Value)))),
JArray array => new JArray(array.Select(Normalize).OrderBy(x => x.ToString(Newtonsoft.Json.Formatting.None))),
_ => token
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ (nitpick) I would prefer to have this spelled out instead of a switch statement for readability

@dennisdoomen dennisdoomen changed the title Adding without strict ordering Added the option to ignore the order in arrays and collections Sep 28, 2025
@dennisdoomen dennisdoomen requested a review from jnyrup September 28, 2025 11:17
@maximiliysiss maximiliysiss requested a review from jnyrup October 3, 2025 16:20
@maximiliysiss maximiliysiss requested a review from jnyrup October 19, 2025 12:34
@dennisdoomen dennisdoomen merged commit fa7de19 into fluentassertions:master Oct 20, 2025
1 check passed
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.

4 participants