Skip to content

Commit

Permalink
Work around for JSON marshall which escapes certain characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
chainlink committed Aug 3, 2016
1 parent ca5497f commit ab89f3f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion kmscli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/urfave/cli"
"fmt"
"encoding/json"
"bytes"
)

func CheckApp(app string) {
Expand Down Expand Up @@ -123,6 +124,16 @@ func CheckAndAddKey(app, env string) {
}
}
}
func JSONMarshal(v interface{}, unescape bool) ([]byte, error) {
b, err := json.Marshal(v)

if unescape {
b = bytes.Replace(b, []byte("\\u003c"), []byte("<"), -1)
b = bytes.Replace(b, []byte("\\u003e"), []byte(">"), -1)
b = bytes.Replace(b, []byte("\\u0026"), []byte("&"), -1)
}
return b, err
}

func UnmarshalSecrets(input []byte) map[string]interface{} {
var dat map[string]interface{}
Expand All @@ -136,7 +147,7 @@ func UnmarshalSecrets(input []byte) map[string]interface{} {
}

func MarshalSecrets(input interface{}) []byte {
data, err := json.Marshal(input)
data, err := JSONMarshal(input, true)

if(err != nil) {
panic(err)
Expand Down

0 comments on commit ab89f3f

Please sign in to comment.