**Only** `String` and `Symbol` can be hash keys. In your current implementation, so can all of the whitelisted types, hash, array etc, which obviously won't work in JSON. 

You'll need a special (private) method for hash key serialization, which will let through only `String`, will convert `Symbol` and will raise an error otherwise.