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

Fix Issue 24823 - std.json: Allow optionally preserving the order of fields in JSON objects #9064

Merged
merged 2 commits into from
Oct 23, 2024

Conversation

CyberShadow
Copy link
Member

@CyberShadow CyberShadow commented Oct 21, 2024

This is the same goal as #6059 , but a more minimal / conservative approach - instead of adding a policy framework, this is behind a new JSONOptions flag.

In theory this is perfectly backwards compatible, as pre-existing D code will never cause any orderedObject to be created. The orderedObject type is entirely opt-in, whether via JSONOptions.preserveObjectOrder, or created manually by starting from a JSONValue.emptyOrderedObject or the .orderedObject setter.

The only gotcha might be any possible final switch-es over JSONType, let's see what BuildKite says - if this is an issue then JSONType.orderedObject could be moved to a bool instead.

@dlang-bot
Copy link
Contributor

dlang-bot commented Oct 21, 2024

Thanks for your pull request, @CyberShadow!

Bugzilla references

Auto-close Bugzilla Severity Description
24823 enhancement std.json: Allow optionally preserving the order of fields in JSON objects

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#9064"

@CyberShadow
Copy link
Member Author

The only gotcha might be any possible final switch-es over JSONType, let's see what BuildKite says - if this is an issue then JSONType.orderedObject could be moved to a bool instead.

Indeed this was an issue, and, done.

Avoid breaking code that do "final switch" oven JSONType.
@dkorpel dkorpel merged commit d447702 into dlang:master Oct 23, 2024
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants