I'm subprocessing to the hidutil
command in my kb-remap
crate. hidutil
takes what is maybe JSON5 or some custom superset of JSON that supports hex literals as arguments. For example
hidutil property \
--matching '{"VendorID":0x5ac,"ProductID":0x0342}' \
--set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x70000002a}]}'
Currently my program constructs these arguments by serializing a struct using serde_json
. However, given that my program has functionality that allows you to inspect the command that will be subprocessed I would like to output the numbers in the JSON as hex literals.
Is this possible to do with serde
and serde_json
?