gpt4 book ai didi

json - 使用无键数组的答案在 Golang 中解析 JSON

转载 作者:数据小太阳 更新时间:2023-10-29 03:23:37 30 4
gpt4 key购买 nike

<分区>

如果响应带有数据数组如何处理json(在JS中它是通过在索引上获取必要的数据来决定的),我看到我通过Unmarshal将其写入结构,但我无法保存结构中的数组,这样我就可以从键中获取索引,因为没有可以在其上创建结构的键。

package main

import (
"fmt"
"net/http"
)

func main() {
url := "My request"
request := "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + url + "&limit=5&origin=*&format=json"
response, err := http.Get(request)
if err != nil {
fmt.Printf("%s", err)
}

}

下面是答案

["bee",["Bee","Beer","Bee Gees","Beef","Beetle"],["Bees are flying insects closely related to wasps and ants, known for their role in pollination and, in the case of the best-known bee species, the European honey bee, for producing honey and beeswax.","Beer is one of the oldest and most widely consumed alcoholic drinks in the world, and the third most popular drink overall after water and tea.","The Bee Gees were a pop music group formed in 1958. Their lineup consisted of brothers Barry, Robin, and Maurice Gibb.","Beef is the culinary name for meat from cattle, particularly skeletal muscle. Humans have been eating beef since prehistoric times.","Beetles are a group of insects that form the order Coleoptera, in the superorder Endopterygota. Their front pair of wings is hardened into wing-cases, elytra, distinguishing them from most other insects."],["https://en.wikipedia.org/wiki/Bee","https://en.wikipedia.org/wiki/Beer","https://en.wikipedia.org/wiki/Bee_Gees","https://en.wikipedia.org/wiki/Beef","https://en.wikipedia.org/wiki/Beetle"]]

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com