refactor: use tailscale/hujson to support trailing commas after the last member in arrays and lists

This commit is contained in:
Jose Diaz-Gonzalez
2025-11-20 01:00:40 -05:00
parent 318c21996a
commit 54c1ccd9bb
9 changed files with 18 additions and 61 deletions

View File

@@ -8,7 +8,7 @@ import (
"strings"
"github.com/dokku/dokku/plugins/common"
"github.com/marcozac/go-jsonc"
"github.com/tailscale/hujson"
"k8s.io/utils/ptr"
)
@@ -263,13 +263,14 @@ func ReadAppJSON(path string) (AppJSON, error) {
return AppJSON{}, nil
}
data, err := jsonc.Sanitize(b)
ast, err := hujson.Parse(b)
if err != nil {
return AppJSON{}, fmt.Errorf("Cannot sanitize app.json: %v", err)
return AppJSON{}, fmt.Errorf("Cannot parse app.json as jsonc: %v", err)
}
ast.Standardize()
var appJSON AppJSON
if err = json.Unmarshal(data, &appJSON); err != nil {
if err = json.Unmarshal(ast.Pack(), &appJSON); err != nil {
return AppJSON{}, fmt.Errorf("Cannot parse app.json: %v", err)
}