Skip to content

Commit

Permalink
Fix JSON compact output escape character issue
Browse files Browse the repository at this point in the history
Fix issue with the incorrect escape character analog to default JSON output.
  • Loading branch information
HeavyWombat committed Nov 4, 2020
1 parent fce4fdf commit 220ab10
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions output_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ func (p *OutputProcessor) ToCompactJSON(obj interface{}) (string, error) {
return fmt.Sprintf("[%s]", strings.Join(tmp, ", ")), nil

case yamlv3.ScalarNode:
switch tobj.Tag {
case "!!int", "!!float", "!!null", "!!bool":
return tobj.Value, nil
obj, err := cast(*tobj)
if err != nil {
return "", err
}

bytes, err := json.Marshal(obj)
if err != nil {
return "", err
}

return fmt.Sprintf("\"%s\"", tobj.Value), nil
return string(bytes), nil
}

case []interface{}:
Expand Down

0 comments on commit 220ab10

Please sign in to comment.