为了账号安全,请及时绑定邮箱和手机立即绑定

使用 Golang 从 DuckDuckGo 解码 JSON

使用 Golang 从 DuckDuckGo 解码 JSON

Go
Cats萌萌 2021-07-10 09:02:49
我一直在使用DuckDuckGo的Go 库,除了一件事外,它一直运行良好。在“相关主题”部分。通常,它看起来像这样:{"RelatedTopics" : [      {         "Result" : "<a href=\"http://duckduckgo.com/Criticism_of_Google\">Criticism of Google</a> - Criticism of Google includes possible misuse and manipulation of search results, its use of others' intellectual property, concerns that its compilation of data may violate people's privacy, cen...",         "Icon" : {            "URL" : "",            "Height" : "",            "Width" : ""         },         "FirstURL" : "http://duckduckgo.com/Criticism_of_Google",         "Text" : "Criticism of Google - Criticism of Google includes possible misuse and manipulation of search results, its use of others' intellectual property, concerns that its compilation of data may violate people's privacy, cen..."      },      {         "Result" : "<a href=\"http://duckduckgo.com/PRISM_(surveillance_program)\">PRISM</a> - PRISM is a clandestine mass electronic surveillance data mining program known to have been operated by the United States National Security Agency (NSA) since 2007.",         "Icon" : {            "URL" : "",            "Height" : "",            "Width" : ""         },         "FirstURL" : "http://duckduckgo.com/PRISM_(surveillance_program)",         "Text" : "PRISM - PRISM is a clandestine mass electronic surveillance data mining program known to have been operated by the United States National Security Agency (NSA) since 2007."      },但是,有时在“RealtedTopics”部分中,会出现一系列“Topics”,其中包含许多“Results”和该 Topic 的“Name”。
查看完整描述

1 回答

?
慕无忌1623718

TA贡献1744条经验 获得超4个赞

主题似乎包含一个切片Topics []Topic:


type Icon struct {

  URL string

  Height string

  Width string

}


type Topic struct {

  Result string

  Icon Icon

  FirstURL string

  Text string

  Topics []Topic `json:",omitempty"`

}


type RootObj struct {

 RelatedTopics []Topic

}


查看完整回答
反对 回复 2021-07-12
  • 1 回答
  • 0 关注
  • 203 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信