Skip to content

Commit

Permalink
fix: syntax again
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsper2nd committed Apr 1, 2024
1 parent 151d3e1 commit b5e5b79
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions generate/idcac/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,37 +163,28 @@ func main() {
var commons, rules string
var javascriptFixes = make(map[int]string)

// err = jsonextract.Reader(strings.NewReader(string(rulesContent)), func(b []byte) error {
// var data map[string]interface{}
// if err := json.Unmarshal(b, &data); err != nil {
// return err
// }

err = jsonextract.Reader(strings.NewReader(string(rulesContent)), func(b []byte) error {
var data []map[string]interface{}
var data []interface{}
if err := json.Unmarshal(b, &data); err != nil {
return err
}

for _, item := range data {
// Process each rule here
// Example:
if isRules(item) {
rules = string(b)
break // Assuming there's only one ruleset, you can adjust this logic if needed
if rule, ok := item.(map[string]interface{}); ok {
if isRules(rule) {
rules = toJSONString(rule)
break // Assuming there's only one ruleset, you can adjust this logic if needed
}
} else if commonsData, ok := item.(map[string]interface{}); ok {
if isCommons(commonsData) {
commons = toJSONString(commonsData)
break // Assuming there's only one commons set, you can adjust this logic if needed
}
}
}
return nil

})

if isCommons(data) {
commons = string(b)
} else if isRules(data) {
rules = string(b)
}
return nil
}
if err != nil {
log.Fatalf("failed to read/converting rules file: %s\n", err.Error())
}
Expand Down

0 comments on commit b5e5b79

Please sign in to comment.