From 851cc327e5e451f25c80a3cf231f94005de0b25d Mon Sep 17 00:00:00 2001 From: brent s Date: Mon, 13 Dec 2021 04:25:45 -0500 Subject: [PATCH] fix JSON marshaling for SecretValue. --- secretvalue_funcs.go | 6 +++++- types.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/secretvalue_funcs.go b/secretvalue_funcs.go index 7571968..c559100 100644 --- a/secretvalue_funcs.go +++ b/secretvalue_funcs.go @@ -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 } diff --git a/types.go b/types.go index 582b9ef..9cce73d 100644 --- a/types.go +++ b/types.go @@ -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