Skip to content

Commit

Permalink
controller: printStruct -> printAsJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
sj14 committed Apr 30, 2024
1 parent fa29a24 commit 443a396
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"log"
"reflect"
"strings"

jellyapi "github.com/sj14/jellyfin-go/api"
)
Expand All @@ -27,16 +26,13 @@ func pointer[T any](v T) *T {
return &v
}

func printStruct(v any) {
j, err := json.MarshalIndent(v, "", "")
func printAsJSON(v any) {
j, err := json.MarshalIndent(v, "", " ")
if err != nil {
log.Fatalln(err)
}

output := strings.ReplaceAll(string(j), "\"", "")
output = strings.Trim(output, "{}")
output = strings.TrimSpace(output)
fmt.Println(output)
fmt.Println(string(j))
}

// Set all fields which are nil to the zero value.
Expand Down
4 changes: 2 additions & 2 deletions controller/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ func (c *Controller) GetSystemInfo() error {
return err
}

printStruct(result)
printAsJSON(result)
return err
}

Expand All @@ -16,7 +16,7 @@ func (c *Controller) GetPublicSystemInfo() error {
return err
}

printStruct(result)
printAsJSON(result)
return err
}

Expand Down

0 comments on commit 443a396

Please sign in to comment.