mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
20 lines
500 B
Go
20 lines
500 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gogf/gf/encoding/gjson"
|
|
)
|
|
|
|
func main() {
|
|
s := `
|
|
{"apiVersion":"v1","kind":"Service","metadata":{"labels":{"name":"http-daemon"},"name":"http-daemon","namespace":"default"},"spec":{"ports":[{"name":"http-daemon","port":8080,"protocol":"TCP","targetPort":9212}],"selector":{"app":"http-daemon","version":"v0930-082326"}}}
|
|
`
|
|
js, err := gjson.DecodeToJson(s)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
//g.Dump(js.ToMap())
|
|
y, _ := js.ToYamlString()
|
|
fmt.Println(y)
|
|
}
|