add buildin function yamli for package gview

This commit is contained in:
John Guo
2022-01-17 17:10:44 +08:00
parent c72a9f2e1e
commit 56f88f759a
6 changed files with 62 additions and 2 deletions

View File

@ -120,6 +120,12 @@ func (j *Json) ToYaml() ([]byte, error) {
return gyaml.Encode(*(j.p))
}
func (j *Json) ToYamlIndent(indent string) ([]byte, error) {
j.mu.RLock()
defer j.mu.RUnlock()
return gyaml.EncodeIndent(*(j.p), indent)
}
func (j *Json) ToYamlString() (string, error) {
b, e := j.ToYaml()
return string(b), e
@ -170,8 +176,6 @@ func (j *Json) MustToTomlString() string {
// ToIni json to ini
func (j *Json) ToIni() ([]byte, error) {
j.mu.RLock()
defer j.mu.RUnlock()
return gini.Encode(j.Map())
}