json
json copied to clipboard
serialize_bytes should serialize to a string if the bytes are ASCII
There are cases when byte strings are human-readable in ASCII form, but are represented as &[u8] instead of &str.
It would be nice if serde_json's serialize_bytes impl would detect if a byte array is all ASCII, and if so, serialize it as a string rather than as a sequence of integers. This would result in more human-readable output. On parsing, this case is easily handled by adding a visit_str impl that reads the string to a byte array.