Skip to content

Commit 92e4b07

Browse files
committed
fix json (#622)
1 parent c855087 commit 92e4b07

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

types/json.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func (b *JSONBuilder) Append(v any) {
2929
return
3030
}
3131

32-
data, err := json.MarshalNoEscape(v) // per https://github.com/cloudquery/plugin-sdk/issues/622
32+
// per https://github.com/cloudquery/plugin-sdk/issues/622
33+
data, err := json.MarshalWithOption(v, json.DisableHTMLEscape())
3334
if err != nil {
3435
panic(err)
3536
}
@@ -38,7 +39,8 @@ func (b *JSONBuilder) Append(v any) {
3839
}
3940

4041
func (b *JSONBuilder) UnsafeAppend(v any) {
41-
data, err := json.MarshalNoEscape(v) // per https://github.com/cloudquery/plugin-sdk/issues/622
42+
// per https://github.com/cloudquery/plugin-sdk/issues/622
43+
data, err := json.MarshalWithOption(v, json.DisableHTMLEscape())
4244
if err != nil {
4345
panic(err)
4446
}
@@ -61,7 +63,8 @@ func (b *JSONBuilder) AppendValues(v []any, valid []bool) {
6163
if !valid[i] {
6264
continue
6365
}
64-
data[i], err = json.Marshal(v[i])
66+
// per https://github.com/cloudquery/plugin-sdk/issues/622
67+
data[i], err = json.MarshalWithOption(v[i], json.DisableHTMLEscape())
6568
if err != nil {
6669
panic(err)
6770
}
@@ -135,9 +138,9 @@ func (a *JSONArray) Value(i int) any {
135138
return nil
136139
}
137140

138-
arr := a.Storage().(*array.Binary)
139141
var data any
140-
err := json.UnmarshalNoEscape(arr.Value(i), &data)
142+
// per https://github.com/cloudquery/plugin-sdk/issues/622
143+
err := json.UnmarshalNoEscape(a.Storage().(*array.Binary).Value(i), &data)
141144
if err != nil {
142145
panic(fmt.Errorf("invalid json: %w", err))
143146
}
@@ -160,13 +163,14 @@ func (a *JSONArray) MarshalJSON() ([]byte, error) {
160163
if a.IsNull(i) {
161164
continue
162165
}
163-
166+
// per https://github.com/cloudquery/plugin-sdk/issues/622
164167
err := json.UnmarshalNoEscape(arr.Value(i), &values[i])
165168
if err != nil {
166169
panic(fmt.Errorf("invalid json: %w", err))
167170
}
168171
}
169-
return json.Marshal(values)
172+
// per https://github.com/cloudquery/plugin-sdk/issues/622
173+
return json.MarshalWithOption(values, json.DisableHTMLEscape())
170174
}
171175

172176
func (a *JSONArray) GetOneForMarshal(i int) any {

0 commit comments

Comments
 (0)