dtolnay/serde-yaml

Why are hexadecimal representation of integers emitted in yaml with single quotes around them?

noppej opened this issue · 1 comments

Hi,

If I have a string in my YAML, such as start: 0x20000000 then it deserializes correctly as a u64.

However, when I use serializer.serialize_str(format!("{:#010x}", memory_address).as_str()), it will write the yaml with single quotes, e.g. start: '0x20000000', which obviously won't round-trip/deserialize as u64.

Am I missing something? Is there an easy way to remove those pesky single-quotes?

which obviously won't round-trip/deserialize as u64.

It will round-trip as a string. Going from serde string (serialize_str) to YAML to u64 is not a "round-trip". Going from serde string to YAML to serde string is a round-trip. If this string value got serialized without quoted, it would not round trip.

Controlling the hex format of serialize_u64 is not something that I would want in this library, but it would be reasonable for someone else to implement a more fully featured YAML library for it.