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

Autogenerated MarshalJSON function does not respect ordering #193

Open
galion96 opened this issue Aug 2, 2022 · 0 comments
Open

Autogenerated MarshalJSON function does not respect ordering #193

galion96 opened this issue Aug 2, 2022 · 0 comments

Comments

@galion96
Copy link

galion96 commented Aug 2, 2022

Hello,

I am using this library as a validator before streaming data to PubSub, and since avro requires a strict order I assumed that
MarshalJSON is ment to respect that ordering, and the method does seem to do some only to call json.Marhsal in the end and ruin the order.
Is this intended?
Code example that was autogenerated from avro schema-

function(r SomeStruct) MarshalJSON() ([]byte, error) {
	var err error
	output := make(map[string]json.RawMessage)
	output["filedA"], err = json.Marshal(r.fieldA)
	if err != nil {
		return nil, err
	}
	output["fieldB"], err = json.Marshal(r.fieldB)
	if err != nil {
		return nil, err
	}
	output["fieldC"], err = json.Marshal(r.fieldC)
	if err != nil {
		return nil, err
	}
	output["fieldD"], err = json.Marshal(r.fieldD)
	if err != nil {
		return nil, err
	}
	output["fieldE"], err = json.Marshal(r.fieldE)
	if err != nil {
		return nil, err
	}
	return json.Marshal(output)

Is this intended?

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

No branches or pull requests

1 participant