Skip to content

Commit 180cd93

Browse files
author
Simple-Tracker
committed
Fix JSON comment bug
1 parent 5f26718 commit 180cd93

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func SetBlockListFromFile() bool {
266266

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

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

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

417417
var content []string
418418
if strings.HasSuffix(httpHeader.Get("Content-Type"), "json") {
419-
err := json.Unmarshal(ipBlockListContent, &content)
419+
err := json.Unmarshal(jsonc.ToJSON(ipBlockListContent), &content)
420420
if err != nil {
421421
Log("SetIPBlockListFromURL", GetLangText("Error-GenJSONWithID"), true, ipBlockListURL, err.Error())
422422
continue

i18n.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66

77
"github.com/Xuanwo/go-locale"
8+
"github.com/tidwall/jsonc"
89
)
910

1011
var langContent map[string]string
@@ -136,7 +137,7 @@ func LoadLang(langCode string) bool {
136137
return false
137138
}
138139

139-
if err := json.Unmarshal(langFile, &langContent); err != nil {
140+
if err := json.Unmarshal(jsonc.ToJSON(langFile), &langContent); err != nil {
140141
Log("LoadLang", GetLangText("Error-ParseLang"), false, langPath, err.Error())
141142
return false
142143
}

0 commit comments

Comments
 (0)