mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2026-03-15 14:03:17 +08:00
* rewrite * update submodule * make width height configurable * update dependency * update * update file * update dep * fix basic config layout * update plugin management * more stuff * add blacklist * fix todo * fix windows gethandle * update windows update guide * update windows build guide * include go mod tidy in script * update todo * fix source session * fix text output * add plugin play duration control * fix id diange not working * update todo * update version number
34 lines
697 B
Go
34 lines
697 B
Go
package util
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
)
|
|
|
|
func MarshalUnescape(v interface{}) (string, error) {
|
|
bf := bytes.NewBuffer([]byte{})
|
|
jsonEncoder := json.NewEncoder(bf)
|
|
jsonEncoder.SetEscapeHTML(false)
|
|
err := jsonEncoder.Encode(v)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return bf.String(), nil
|
|
}
|
|
|
|
func MarshalIndentUnescape(v interface{}, prefix, indent string) (string, error) {
|
|
bf := bytes.NewBuffer([]byte{})
|
|
jsonEncoder := json.NewEncoder(bf)
|
|
jsonEncoder.SetEscapeHTML(false)
|
|
err := jsonEncoder.Encode(v)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
var buf bytes.Buffer
|
|
err = json.Indent(&buf, bf.Bytes(), prefix, indent)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return buf.String(), nil
|
|
}
|