Custom serializer in pretty printer for binary fields #3940
-
Hi! I'd like the pretty printer to print binary as hex instead of base64. I've created a mapper and custom serializer for byte[].class that works in other contexts, but not in the pretty printer derived from that mapper, which still emits base64. Any hints? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Pretty printer really should not change serialization aspects; it should invoke all the usual handling so this sounds odd and not at all like expected. |
Beta Was this translation helpful? Give feedback.
-
My assumption was incorrect. I had a bunch of serializers for special objects "BlahAsBytesSerializer" in a module (for CBORMapper), so by just adding "BinaryAsHex" serializer to the end of same module and using the module with ObjectMapper (used for printing) did not "stack". A member of type Blah was first converted to byte[] and then printed as base64 whereas a simple byte[] was indeed serialized as hex. "fixed" this by making "BlahAsHex" serializer. Would be cool if the mapper respected such two stage conversions, first from custom object to byte[] and then because same module has a serializer for byte[], would use that? |
Beta Was this translation helpful? Give feedback.
My assumption was incorrect. I had a bunch of serializers for special objects "BlahAsBytesSerializer" in a module (for CBORMapper), so by just adding "BinaryAsHex" serializer to the end of same module and using the module with ObjectMapper (used for printing) did not "stack". A member of type Blah was first converted to byte[] and then printed as base64 whereas a simple byte[] was indeed serialized as hex.
"fixed" this by making "BlahAsHex" serializer. Would be cool if the mapper respected such two stage conversions, first from custom object to byte[] and then because same module has a serializer for byte[], would use that?