package main


import (

    "encoding/json"

    "fmt"

)


type PublicKey struct {

    name string

    price string

}


type KeysResponse struct {

    Collection []PublicKey

}


func main() {

    s := `[{"name":"Galaxy Nexus", "price":"3460.00"},{"name":"Galaxy Nexus", "price":"3460.00"}]`


    keys := make([]PublicKey,0)

    err := json.Unmarshal([]byte(s), &keys)

    if err == nil {

        fmt.Printf("%+v\n", keys)

    } else {

        fmt.Println(err)

        fmt.Printf("%+v\n", keys)

    }

}

输出: [{name: price:}]


我有 api 调用返回的结果就像对象数组(json 数组)复杂格式。我需要通过 golang 解析该结果,我该如何实现?以下数据是我从 api 调用获得的结果。