Skip to content

Commit db5d04b

Browse files
committed
renamed utils to jsonutils
1 parent 89af207 commit db5d04b

File tree

1 file changed

+3
-38
lines changed

1 file changed

+3
-38
lines changed

utils/utils.go renamed to utils/jsonutils/jsonutils.go

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
package utils
2-
3-
/*
4-
* General Functions (utils)
5-
* Might move Functions into seperate files
6-
*/
1+
package jsonutils
72

83
import (
94
"encoding/json"
105
"regexp"
116
"strconv"
12-
13-
"gopkg.in/yaml.v3"
147
)
158

169
func GetByPath(path string, data any) (any, bool) {
@@ -67,31 +60,7 @@ func GetJsonSafe[T any](jsonStr string) (T, error) {
6760
func GetJson[T any](jsonStr string) (T) {
6861
var result T
6962

70-
err := json.Unmarshal([]byte(jsonStr), &result)
71-
72-
if err != nil {
73-
// YML is empty
74-
}
75-
76-
return result
77-
}
78-
79-
func GetYmlSafe[T any](ymlStr string) (T, error) {
80-
var result T
81-
82-
err := yaml.Unmarshal([]byte(ymlStr), &result)
83-
84-
return result, err
85-
}
86-
87-
func GetYml[T any](ymlStr string) (T) {
88-
var result T
89-
90-
err := yaml.Unmarshal([]byte(ymlStr), &result)
91-
92-
if err != nil {
93-
// YML is empty
94-
}
63+
json.Unmarshal([]byte(jsonStr), &result)
9564

9665
return result
9766
}
@@ -103,11 +72,7 @@ func ToJsonSafe[T any](obj T) (string, error) {
10372
}
10473

10574
func ToJson[T any](obj T) string {
106-
bytes, err := json.Marshal(obj)
107-
108-
if err != nil {
109-
// JSON is empty
110-
}
75+
bytes, _ := json.Marshal(obj)
11176

11277
return string(bytes)
11378
}

0 commit comments

Comments
 (0)