1 Star 0 Fork 1

landy / qlang

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
json.go 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
xushiwei 提交于 2016-05-21 14:48 . #71 gomodule._name
package json
import (
"encoding/json"
"strings"
"syscall"
)
// -----------------------------------------------------------------------------
// Pretty prints a value in pretty mode.
//
func Pretty(v interface{}) string {
b, err := json.MarshalIndent(v, "", " ")
if err != nil {
return err.Error()
}
return string(b)
}
// Unmarshal unmarshals a []byte or string
//
func Unmarshal(b interface{}) (v interface{}, err error) {
switch in := b.(type) {
case []byte:
err = json.Unmarshal(in, &v)
case string:
err = json.NewDecoder(strings.NewReader(in)).Decode(&v)
default:
err = syscall.EINVAL
}
return
}
// Exports is the export table of this module.
//
var Exports = map[string]interface{}{
"_name": "encoding/json",
"decoder": json.NewDecoder,
"encoder": json.NewEncoder,
"marshal": json.Marshal,
"marshalIndent": json.MarshalIndent,
"pretty": Pretty,
"unmarshal": Unmarshal,
"compact": json.Compact,
"indent": json.Indent,
"htmlEscape": json.HTMLEscape,
}
// -----------------------------------------------------------------------------
Go
1
https://gitee.com/landylee007/qlang.git
git@gitee.com:landylee007/qlang.git
landylee007
qlang
qlang
v2.9.60

搜索帮助