fix JSON marshaling for SecretValue.

This commit is contained in:
brent s. 2021-12-13 04:25:45 -05:00
parent 09f3c9b73e
commit 851cc327e5
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,9 @@
package gosecret

import (
`fmt`
)

/*
MarshalJSON converts a SecretValue to a JSON representation.
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) {

b = []byte(string(*s))
b = []byte(fmt.Sprintf("\"%v\"", string(*s)))

return
}

View File

@ -169,5 +169,5 @@ type Secret struct {
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