fix JSON marshaling for SecretValue.
This commit is contained in:
parent
09f3c9b73e
commit
851cc327e5
@ -1,5 +1,9 @@
|
|||||||
package gosecret
|
package gosecret
|
||||||
|
|
||||||
|
import (
|
||||||
|
`fmt`
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MarshalJSON converts a SecretValue to a JSON representation.
|
MarshalJSON converts a SecretValue to a JSON representation.
|
||||||
For compat reasons, the MarshalText is left "unmolested" (i.e. renders to a Base64 value).
|
For compat reasons, the MarshalText is left "unmolested" (i.e. renders to a Base64 value).
|
||||||
@ -7,7 +11,7 @@ package gosecret
|
|||||||
*/
|
*/
|
||||||
func (s *SecretValue) MarshalJSON() (b []byte, err error) {
|
func (s *SecretValue) MarshalJSON() (b []byte, err error) {
|
||||||
|
|
||||||
b = []byte(string(*s))
|
b = []byte(fmt.Sprintf("\"%v\"", string(*s)))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
2
types.go
2
types.go
@ -169,5 +169,5 @@ type Secret struct {
|
|||||||
session *Session
|
session *Session
|
||||||
}
|
}
|
||||||
|
|
||||||
// SecretValue is a custom type that handles JSON encoding/decoding a little more easily.
|
// SecretValue is a custom type that handles JSON encoding a little more easily.
|
||||||
type SecretValue []byte
|
type SecretValue []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user