moov-io / iso8583

A golang implementation to marshal and unmarshal iso8583 message.
https://moov.io
Apache License 2.0
304 stars 100 forks source link

Fix ordering when serialize message into JSON #125

Closed alovak closed 10 months ago

alovak commented 2 years ago

When we serialize messages into JSON, we convert field IDs from ints into strings and then sort them using OrderedMap. Here is an example of what we may get when we have 17 and 107 as IDs:

{ "0":"0100", "1":"D00080000000000000000000002000000000000000000000", "107":"102", "17":"101", "2":"4242424242424242", "4":"100" }

I think that we may keep OrderedMap as is for numeric IDs (when we use it in message) and just use default JSON marshalling for a composite field without sorting. Or, we may add OrderedStringMap in addition to Ordered(Int)Map for the composite field.

It was changed here: https://github.com/moov-io/iso8583/pull/121/files#r706258805

Scratch-net commented 2 years ago

Any plans to fix this ? :) it's very annoying