@@ -13,14 +13,15 @@ var _json = jsonI.ConfigCompatibleWithStandardLibrary
13
13
// during marshalling, it returns the error.
14
14
//
15
15
// Parameters:
16
- // - `v`: The Go value to be marshalled into JSON.
16
+ // - `v`: The Go value to be marshalled into JSON.
17
17
//
18
18
// Returns:
19
- // - A byte slice containing the JSON representation of the input value.
20
- // - An error if the marshalling fails.
19
+ // - A byte slice containing the JSON representation of the input value.
20
+ // - An error if the marshalling fails.
21
21
//
22
22
// Example:
23
- // jsonData, err := Marshal(myStruct)
23
+ //
24
+ // jsonData, err := Marshal(myStruct)
24
25
func Marshal (v interface {}) ([]byte , error ) {
25
26
return _json .Marshal (v )
26
27
}
@@ -32,16 +33,17 @@ func Marshal(v interface{}) ([]byte, error) {
32
33
// It returns the resulting JSON byte slice or an error if marshalling fails.
33
34
//
34
35
// Parameters:
35
- // - `v`: The Go value to be marshalled into JSON.
36
- // - `prefix`: A string that will be prefixed to each line of the output JSON.
37
- // - `indent`: A string used for indentation (typically a series of spaces or a tab).
36
+ // - `v`: The Go value to be marshalled into JSON.
37
+ // - `prefix`: A string that will be prefixed to each line of the output JSON.
38
+ // - `indent`: A string used for indentation (typically a series of spaces or a tab).
38
39
//
39
40
// Returns:
40
- // - A byte slice containing the formatted JSON representation of the input value.
41
- // - An error if the marshalling fails.
41
+ // - A byte slice containing the formatted JSON representation of the input value.
42
+ // - An error if the marshalling fails.
42
43
//
43
44
// Example:
44
- // jsonIndented, err := MarshalIndent(myStruct, "", " ")
45
+ //
46
+ // jsonIndented, err := MarshalIndent(myStruct, "", " ")
45
47
func MarshalIndent (v interface {}, prefix , indent string ) ([]byte , error ) {
46
48
return _json .MarshalIndent (v , prefix , indent )
47
49
}
@@ -53,14 +55,15 @@ func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
53
55
// JSON string. If an error occurs during the process, it returns an error.
54
56
//
55
57
// Parameters:
56
- // - `v`: The Go value to be marshalled into JSON.
58
+ // - `v`: The Go value to be marshalled into JSON.
57
59
//
58
60
// Returns:
59
- // - A string containing the JSON representation of the input value.
60
- // - An error if the marshalling fails.
61
+ // - A string containing the JSON representation of the input value.
62
+ // - An error if the marshalling fails.
61
63
//
62
64
// Example:
63
- // jsonString, err := MarshalToString(myStruct)
65
+ //
66
+ // jsonString, err := MarshalToString(myStruct)
64
67
func MarshalToString (v interface {}) (string , error ) {
65
68
return _json .MarshalToString (v )
66
69
}
@@ -72,14 +75,15 @@ func MarshalToString(v interface{}) (string, error) {
72
75
// is successful, it populates the value `v`. If an error occurs, it returns the error.
73
76
//
74
77
// Parameters:
75
- // - `data`: A byte slice containing JSON data to be unmarshalled.
76
- // - `v`: A pointer to the Go value where the unmarshalled data will be stored.
78
+ // - `data`: A byte slice containing JSON data to be unmarshalled.
79
+ // - `v`: A pointer to the Go value where the unmarshalled data will be stored.
77
80
//
78
81
// Returns:
79
- // - An error if the unmarshalling fails.
82
+ // - An error if the unmarshalling fails.
80
83
//
81
84
// Example:
82
- // err := Unmarshal(jsonData, &myStruct)
85
+ //
86
+ // err := Unmarshal(jsonData, &myStruct)
83
87
func Unmarshal (data []byte , v interface {}) error {
84
88
return _json .Unmarshal (data , v )
85
89
}
@@ -91,14 +95,15 @@ func Unmarshal(data []byte, v interface{}) error {
91
95
// successful, it populates the value `v`. If an error occurs, it returns the error.
92
96
//
93
97
// Parameters:
94
- // - `str`: A string containing JSON data to be unmarshalled.
95
- // - `v`: A pointer to the Go value where the unmarshalled data will be stored.
98
+ // - `str`: A string containing JSON data to be unmarshalled.
99
+ // - `v`: A pointer to the Go value where the unmarshalled data will be stored.
96
100
//
97
101
// Returns:
98
- // - An error if the unmarshalling fails.
102
+ // - An error if the unmarshalling fails.
99
103
//
100
104
// Example:
101
- // err := UnmarshalFromString(jsonString, &myStruct)
105
+ //
106
+ // err := UnmarshalFromString(jsonString, &myStruct)
102
107
func UnmarshalFromString (str string , v interface {}) error {
103
108
return _json .UnmarshalFromString (str , v )
104
109
}
@@ -110,13 +115,14 @@ func UnmarshalFromString(str string, v interface{}) error {
110
115
// MarshalToString function. If an error occurs during marshalling, it returns an empty string.
111
116
//
112
117
// Parameters:
113
- // - `data`: The Go value to be converted to JSON, or a string to be returned directly.
118
+ // - `data`: The Go value to be converted to JSON, or a string to be returned directly.
114
119
//
115
120
// Returns:
116
- // - A string containing the JSON representation of the input value, or an empty string if an error occurs.
121
+ // - A string containing the JSON representation of the input value, or an empty string if an error occurs.
117
122
//
118
123
// Example:
119
- // jsonStr := Json(myStruct)
124
+ //
125
+ // jsonStr := Json(myStruct)
120
126
func Json (data interface {}) string {
121
127
s , ok := data .(string )
122
128
if ok {
@@ -136,13 +142,14 @@ func Json(data interface{}) string {
136
142
// the MarshalIndent function. If an error occurs during marshalling, it returns an empty string.
137
143
//
138
144
// Parameters:
139
- // - `data`: The Go value to be converted to pretty-printed JSON, or a string to be returned directly.
145
+ // - `data`: The Go value to be converted to pretty-printed JSON, or a string to be returned directly.
140
146
//
141
147
// Returns:
142
- // - A string containing the pretty-printed JSON representation of the input value, or an empty string if an error occurs.
148
+ // - A string containing the pretty-printed JSON representation of the input value, or an empty string if an error occurs.
143
149
//
144
150
// Example:
145
- // jsonPrettyStr := JsonPretty(myStruct)
151
+ //
152
+ // jsonPrettyStr := JsonPretty(myStruct)
146
153
func JsonPretty (data interface {}) string {
147
154
s , ok := data .(string )
148
155
if ok {
0 commit comments