-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSON serialize Vec<u8> fields as hex
serde_json has no simple way to serialize specific field types as hex, until specialization is merged. This commit contains a hack to serialize all Vec<u8> fields as hex anyway. It is impossible to check the type of a generic type parameter at runtime. So all values are first serialized, then attempted to deserialize into a Vec<u8>. If that works, the found vector will be serialized as a hex string, rather than an array of numbers. This is not a performant machanism, but it gets the job done. As long as it is only used for dev commands and diagnostic data it should be fine. At least all those number arrays in the diagnostic data are now gone, without having to duplicate every struct definition just for serialization. Note that the 'Value' serialization is a copy of the real one.
- Loading branch information
Showing
7 changed files
with
923 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.