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

#193: MarshalJSON preserves avro schema ordering #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

galion96
Copy link

@galion96 galion96 commented Aug 2, 2022

#193

Since avro field order is important, and json.Marshal doesn't preserve the same ordering as struct has, I added this approach (which does generate a fair amount of code) but seems to be working.

I would add the test case for this but not sure since I am not that much into the codebase.
I did however test it locally.

And this way if we have a struct like

fields{ A: "a", C: "c", D: "d", B: "b", Z: "z", E: "e", }
The order would always be after marshaling:

{"a":"a","c":"c","d":"d","b":"b","z":"z","e":"e"}

Edit: now to think about it maybe the template should only call json.Marshal and since it's a struct it should be fine.

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.

1 participant