From b07f52210d230934905bdafcecfb5af7240fd1a3 Mon Sep 17 00:00:00 2001 From: PokeGuys <5060799+PokeGuys@users.noreply.github.com> Date: Wed, 7 Aug 2024 02:15:52 +0800 Subject: [PATCH] fix: unescape html entity in json encoder --- cmd/crawler/crawler.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/crawler/crawler.go b/cmd/crawler/crawler.go index 91ab2b4..aaf481d 100644 --- a/cmd/crawler/crawler.go +++ b/cmd/crawler/crawler.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "encoding/json" "fmt" "log" @@ -36,11 +37,13 @@ func main() { // Print the results in JSON format if cfg.PrintJSON { - b, err := json.Marshal(apk) - if err != nil { + enc := json.NewEncoder(os.Stdout) + buf := new(bytes.Buffer) + enc.SetEscapeHTML(false) + if err := enc.Encode(apk); err != nil { log.Fatal(err.Error()) } - fmt.Println(string(b)) + fmt.Println(string(buf.Bytes())) return }