File tree Expand file tree Collapse file tree 1 file changed +3
-38
lines changed Expand file tree Collapse file tree 1 file changed +3
-38
lines changed Original file line number Diff line number Diff line change 1- package utils
2-
3- /*
4- * General Functions (utils)
5- * Might move Functions into seperate files
6- */
1+ package jsonutils
72
83import (
94 "encoding/json"
105 "regexp"
116 "strconv"
12-
13- "gopkg.in/yaml.v3"
147)
158
169func GetByPath (path string , data any ) (any , bool ) {
@@ -67,31 +60,7 @@ func GetJsonSafe[T any](jsonStr string) (T, error) {
6760func 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
10574func 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}
You can’t perform that action at this time.
0 commit comments