diff --git a/main.go b/main.go index 22df244..e26b478 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "context" "encoding/json" "flag" @@ -9,7 +8,6 @@ import ( "log" "net/url" "os" - "reflect" "sort" "strings" "time" @@ -398,39 +396,10 @@ func main() { } // Output final results in JSON - // TODO - manually generate JSON since Marshal doesn't care about field ordering if len(combined) > 0 { - var b []byte - buf := bytes.NewBuffer(b) - buf.WriteRune('{') - l := len(combined) - for i, entry := range combined { - - v := reflect.ValueOf(entry) - t := v.Type() - - for j := 0; j < v.NumField(); j++ { - field := v.Field(j) - fieldType := t.Field(j) - - km, _ := json.Marshal(fieldType.Name) - buf.Write(km) - buf.WriteRune(':') - - vm, _ := json.Marshal(field.Interface()) - buf.Write(vm) - if i != l-1 { - buf.WriteRune(',') - } - } - } - buf.WriteRune('}') - fmt.Println(buf.String()) - - //j, _ := json.Marshal(combined) - //fmt.Println(string(j)) + j, _ := json.Marshal(combined) + fmt.Println(string(j)) } else { fmt.Println("{}") } - }