make json data printable

This commit is contained in:
ajatprabha 2021-09-18 17:55:59 +05:30 committed by Ken Hibino
parent 3839f96b44
commit c98d65dcdb

View File

@ -1,6 +1,7 @@
package asynqmon package asynqmon
import ( import (
"encoding/json"
"time" "time"
"unicode" "unicode"
"unicode/utf8" "unicode/utf8"
@ -226,6 +227,9 @@ func isPrintable(data []byte) bool {
if !utf8.Valid(data) { if !utf8.Valid(data) {
return false return false
} }
if json.Valid(data) {
return true
}
isAllSpace := true isAllSpace := true
for _, r := range string(data) { for _, r := range string(data) {
if !unicode.IsPrint(r) { if !unicode.IsPrint(r) {