Refactoring JSON encoder prefs

This commit is contained in:
Mike Farah
2024-02-24 15:48:59 +11:00
parent 7a01e216c4
commit 55f6a3a49d
9 changed files with 76 additions and 21 deletions
+25
View File
@@ -0,0 +1,25 @@
package yqlib
type JsonPreferences struct {
Indent int
ColorsEnabled bool
UnwrapScalar bool
}
func NewDefaultJsonPreferences() JsonPreferences {
return JsonPreferences{
Indent: 2,
ColorsEnabled: true,
UnwrapScalar: true,
}
}
func (p *JsonPreferences) Copy() JsonPreferences {
return JsonPreferences{
Indent: p.Indent,
ColorsEnabled: p.ColorsEnabled,
UnwrapScalar: p.UnwrapScalar,
}
}
var ConfiguredJsonPreferences = NewDefaultJsonPreferences()