You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to json marshal and unmarshal net.IPNet objects, but the net.IPMask object currently does not support marshalling to text formats in a human readable/parsable format. When a net.IPMask object is attempted to be json marshalled, it is currently being transformed from a byte slice to a base64 string (as per the encode/json standards).
Right now I am working around this, through type aliasing and methods, but it would be nice if this were either in its hex format, that it is displayed as in when using the String method to keep with backwards compatibility.
This seems to be a somewhat known issue to some regard as it is mentioned within a previous issue, although not yet followed up upon from what I was able to see: #29678 (comment)
Ideally in a future update, it would be great if the IPMask String method and potentially this text marshal were in a more well known format such as dot-decimal notation, for IPv4 instead of encoded to hex, as it is currently displayed, but that sounds like another issue aside from the json marshaling issue I am currently filing for.
What did you expect to see?
I expect net.IPMask to be marshaled to a text format, and consistent with net.IP and enable net.IPNet to be json marshaled leaving all objects in a human readable/parsable format.
What did you see instead?
A json marshaled version of these items in a non human readable fashion (base64 encoded translation of the byte slice).
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm trying to json marshal and unmarshal
net.IPNet
objects, but thenet.IPMask
object currently does not support marshalling to text formats in a human readable/parsable format. When anet.IPMask
object is attempted to be json marshalled, it is currently being transformed from a byte slice to a base64 string (as per theencode/json
standards).Here's an example:
https://play.golang.org/p/EGjSJeVQ9W-
Right now I am working around this, through type aliasing and methods, but it would be nice if this were either in its hex format, that it is displayed as in when using the
String
method to keep with backwards compatibility.This seems to be a somewhat known issue to some regard as it is mentioned within a previous issue, although not yet followed up upon from what I was able to see: #29678 (comment)
Ideally in a future update, it would be great if the IPMask
String
method and potentially this text marshal were in a more well known format such as dot-decimal notation, for IPv4 instead of encoded to hex, as it is currently displayed, but that sounds like another issue aside from the json marshaling issue I am currently filing for.What did you expect to see?
I expect
net.IPMask
to be marshaled to a text format, and consistent withnet.IP
and enablenet.IPNet
to be json marshaled leaving all objects in a human readable/parsable format.What did you see instead?
A json marshaled version of these items in a non human readable fashion (base64 encoded translation of the byte slice).
The text was updated successfully, but these errors were encountered: