I have a use case where the input payload consumed by my REST endpoint should flush it in the same order.
There is no specific pattern to the input, so I'm saving it as map[string]interface{}
and that is causing the issue. Because the input is not mapped to a specific struct the original order is not getting honoured and is getting randomised.
I know that's how map[string]interface{}
is supposed to work but is there a way to retain or get the original order ?
The only solution I can think off is, not to use map[string]interface{}
but to save the payload to a file, process it from there and then flush it out at the end. --> If this is the solution that I should perceive, then, what additional checks should I consider since this involves files. The endpoint is very lightweight, payload is considerably small with less parallel calls.
edit1:
example input payload,
{
"foo": "bar",
"test": "testing",
"example": 1,
"nested": {
"foo": "foo-nested",
"key": 1,
},
}