avro icon indicating copy to clipboard operation
avro copied to clipboard

Deserialize avro messages to JSON and preserve field order

Open weeco opened this issue 3 years ago • 3 comments

Hey, is it possible to deserialize an avro message to a JSON / text format which also preserves the order of the fields as defined in the avro schema? Currently I unmarshal the avro message to an interface{} and then I apply json.Unmarshal() on it which works fine, but the fields are ordered alphabetically rather than in the order as defined in the schema.

weeco avatar Nov 24 '22 11:11 weeco

Hi,

No. This repo does not handle the text representation at all, it is entirely focused on the binary representation.

nrwiersma avatar Nov 24 '22 11:11 nrwiersma

@nrwiersma Thanks for the speedy response. Would you accept PRs for such a method that or is this something you don't want to have as part of this library. Unfortunately I don't see a workaround, because the field order information is lost after the unmarshal process I believe.

weeco avatar Nov 24 '22 12:11 weeco

I would accept PRs for this feature, but I would put it in a json package to not pollute the main codebase.

nrwiersma avatar Nov 24 '22 12:11 nrwiersma