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

Retain message fields in the same order as defined in the .proto file #36

Closed
MalitsPlus opened this issue May 19, 2024 · 0 comments
Closed
Labels
Feature New feature or request

Comments

@MalitsPlus
Copy link

MalitsPlus commented May 19, 2024

While fields in the json string output by protojson are kept in the same order as defined in the .proto file, fields in the yaml string output by protoyaml-go are sorted alphabetically.
This can be a little unfriendly to human reading in some cases. (e.g. We usually define the first field as "id", if sorted alphabetically we will have to scroll down a long way to find it)

It will be very appreciate if protoyaml-go provides an option to let users choose to keep the original order or not.

@Alfus Alfus added the Feature New feature or request label Aug 9, 2024
Alfus added a commit that referenced this issue Aug 12, 2024
see #36
JSON objects are unmarshaled into (unordered) go maps by default. This
PR uses yaml.Node (when possible) instead, which preserves the field
order from protojson.

Note that yaml refuses to parse control characters into yaml.Nodes,
though otherwise handle them correctly.
@Alfus Alfus closed this as completed Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants