Create universal json decode util

This commit is contained in:
cyber-dream 2022-11-02 02:42:40 +03:00
parent 7b9dfe0cee
commit 75e96b9851
2 changed files with 9 additions and 10 deletions

View File

@ -1,9 +1,5 @@
package gameUtils package gameUtils
import (
"encoding/json"
)
func FindGameByID(id string, list Games) SteamGame { func FindGameByID(id string, list Games) SteamGame {
for _, game := range list.SteamGames { for _, game := range list.SteamGames {
if game.GameId == id { if game.GameId == id {
@ -33,9 +29,3 @@ func GetJSGameInterface(game SteamGame) JSGameInterface {
} }
return newInterface return newInterface
} }
func ConvertServerGamesToJSON(g Games) []byte {
g_json, err := json.Marshal(g)
_ = err //TODO: Check Errors
return g_json
}

9
jsonUtils/jsonUtils.go Normal file
View File

@ -0,0 +1,9 @@
package jsonutils
import "encoding/json"
func ConvertToJSON(g interface{}) []byte {
g_json, err := json.Marshal(g)
_ = err //TODO: Check Errors
return g_json
}