pyjson5 icon indicating copy to clipboard operation
pyjson5 copied to clipboard

Hex in generated json

Open omasoud opened this issue 3 years ago • 2 comments

json5 allows numbers to be have hexadecimal representation, but can it generate hexadecimal numbers (via dump/dumps)?

omasoud avatar Oct 06 '21 05:10 omasoud

Not currently, no.

dpranke avatar Oct 06 '21 18:10 dpranke

I'm going to close this, as hopefully the question was answered.

I'm not against implementing this in principle, but in practice it's not obvious to me how one would do this without either adding a flag to dump all numbers in hex (and it is not obvious how useful that would be) or having some way to dump things field-by-field, at which point you're probably better off writing your own dump-like function.

I can also sort of imagine a way one might implement this on top of a more powerful api/implementation like what we'd need to preserve comments (see issue #28): such an implementation could probably also preserve whether the number was decimal or hex and render the value back out in the same format.

dpranke avatar Aug 01 '22 22:08 dpranke