package main

import (
   "fmt"

   "github.com/json-iterator/go"
)

func main() {

   val := []byte(`{"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}`)

   data1 := jsoniter.Get(val, "Colors", 0).ToString()
   fmt.Println(data1)

   data2 := jsoniter.Get(val,"ID").ToInt()
   fmt.Println(data2)
}

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注