Skip to content

Commit

Permalink
Fix JSON comment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Simple-Tracker committed Sep 24, 2024
1 parent 5f26718 commit 180cd93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func SetBlockListFromFile() bool {

var content []string
if filepath.Ext(filePath) == ".json" {
err = json.Unmarshal(blockListContent, &content)
err = json.Unmarshal(jsonc.ToJSON(blockListContent), &content)
if err != nil {
Log("SetBlockListFromFile", GetLangText("Error-GenJSONWithID"), true, filePath, err.Error())
continue
Expand Down Expand Up @@ -305,7 +305,7 @@ func SetBlockListFromURL() bool {

var content []string
if strings.HasSuffix(strings.ToLower(strings.Split(httpHeader.Get("Content-Type"), ";")[0]), "json") {
err := json.Unmarshal(blockListContent, &content)
err := json.Unmarshal(jsonc.ToJSON(blockListContent), &content)
if err != nil {
Log("SetBlockListFromFile", GetLangText("Error-GenJSONWithID"), true, blockListURL, err.Error())
continue
Expand Down Expand Up @@ -380,7 +380,7 @@ func SetIPBlockListFromFile() bool {

var content []string
if filepath.Ext(filePath) == ".json" {
err := json.Unmarshal(ipBlockListFile, &content)
err := json.Unmarshal(jsonc.ToJSON(ipBlockListFile), &content)
if err != nil {
Log("SetIPBlockListFromFile", GetLangText("Error-GenJSONWithID"), true, filePath, err.Error())
}
Expand Down Expand Up @@ -416,7 +416,7 @@ func SetIPBlockListFromURL() bool {

var content []string
if strings.HasSuffix(httpHeader.Get("Content-Type"), "json") {
err := json.Unmarshal(ipBlockListContent, &content)
err := json.Unmarshal(jsonc.ToJSON(ipBlockListContent), &content)
if err != nil {
Log("SetIPBlockListFromURL", GetLangText("Error-GenJSONWithID"), true, ipBlockListURL, err.Error())
continue
Expand Down
3 changes: 2 additions & 1 deletion i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"

"github.com/Xuanwo/go-locale"
"github.com/tidwall/jsonc"
)

var langContent map[string]string
Expand Down Expand Up @@ -136,7 +137,7 @@ func LoadLang(langCode string) bool {
return false
}

if err := json.Unmarshal(langFile, &langContent); err != nil {
if err := json.Unmarshal(jsonc.ToJSON(langFile), &langContent); err != nil {
Log("LoadLang", GetLangText("Error-ParseLang"), false, langPath, err.Error())
return false
}
Expand Down

0 comments on commit 180cd93

Please sign in to comment.