Is there a way to set a custom order to the elements from a JSONEncoder? For example if I have an Encodable
with elements id, message, and error
is there a way to make sure the JSONEncoder returns those elements in that order? Currently it seems to just return data in any order it chooses.
I know there's an option for alphabetically using JSONEncoder.OutputFormatting
and .sortedkeys
but that's not what I'm looking for (also that seems to only work in ios 11). I'm trying to make unit tests where I compare json strings so order is essential.