fix output '\u0026' instead '&'
This commit is contained in:
1 parent
4e6477f213
commit
b65cda4099
3 files changed
+11
-4
No files matched your search
@@ -1,3 +1,5 @@
|
||||
## v2.1.2
|
||||
* fix output '\u0026' instead '&'
|
||||
## v2.1.0
|
||||
* add output format for `status`
|
||||
## v2.0.1
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
@@ -46,10 +47,14 @@ func CheckChangeObject(changeObject string) (string, error) {
|
||||
}
|
||||
|
||||
func PrintAnswer(data interface{}) {
|
||||
if answer, err := json.MarshalIndent(data, "", " "); err != nil {
|
||||
buffer := bytes.NewBuffer(make([]byte, 1024))
|
||||
encoder := json.NewEncoder(buffer)
|
||||
encoder.SetEscapeHTML(false)
|
||||
encoder.SetIndent("", " ")
|
||||
if err := encoder.Encode(data); err != nil {
|
||||
PrintError(err)
|
||||
} else {
|
||||
service.ColorService.Print(answer)
|
||||
service.ColorService.Print(buffer.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +103,7 @@ func ParseSetObject(argument string) interface{} {
|
||||
}
|
||||
|
||||
func CheckObject(jsonObject []byte, depth string) {
|
||||
jsonString := gjson.Get(string(jsonObject), depth)
|
||||
jsonString := gjson.GetBytes(jsonObject, depth)
|
||||
if jsonString.Raw == "" {
|
||||
PrintError(errors.Errorf("path '%s' not found\n", depth))
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user