Make the serde support behave better …
The previous implementation could produce illegal JSON when used with serde_json.