> > You can always serialize things however you want. Using `serialize()` > is just a convenience – there is absolutely nothing that prevents you > from using a custom serialization routine. Note that while Java has > built in serialization it is often not used, and instead libraries > like Google's GSON are used. You register a type with hooks for > serializing and deserializing, etc. > > It sounds like this is what you need anyway. Since built-in > serialization happens differently in each language you'd probably want > something custom in each language. >
Whilst that might be the case with *serialize()*, by extension you also lose the convenience of being able to use *json_encode() *on an already properly structured object and immediately having a representation of that object ready to send over the wire. C#'s enums seem a good model to follow. 0-indexed by default, alternatively you can specify the first key to change to (for example) 1-indexed or specify all keys: enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};