What is the best way to encode a java object to deterministic identifier which I can decode to that object?
Basically I want to send this upstream to clients in our response so that they can report metrics on this identifier. So this identifier has to be deterministic. I've looked into JSON serialization -> GZIP compression -> base64 string. However, I'm worried that the fields in the json object will not always maintain the same order, resulting in a different set of bytes each time. Is there a way to preserve this struct order? If not is there a better way to do this?
Another related question is if there is a method which produces a string with the least number of characters since we have tight space requirements for the resulting identifier.