cmptest: jsondemo (todo)

This commit is contained in:
xushiwei
2024-07-29 01:56:39 +08:00
parent 4cd1629118
commit 53c2558d26
3 changed files with 17 additions and 17 deletions

View File

@@ -0,0 +1,16 @@
package main
import (
"encoding/json"
"fmt"
"unsafe"
)
func main() {
s := `{"name":"math","items":[{"name":"sqrt","sig":"(x, /)"},{"name":"pi"}]}`
data := unsafe.Slice(unsafe.StringData(s), len(s))
var v any
json.Unmarshal(data, &v)
b, _ := json.MarshalIndent(v, "", " ")
fmt.Println(string(b))
}