Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
go中的ASCII到Json_Json_Go_Ascii_Converter - Fatal编程技术网

go中的ASCII到Json

go中的ASCII到Json,json,go,ascii,converter,Json,Go,Ascii,Converter,我对编程有点陌生,但我发现python没有我需要的速度,所以我切换到go,我正在构建一个刮板,我需要将一个看起来像ASCII格式的字符串转换为json,但我找不到任何关于如何在go中实现这一点的好文档 我需要转换的字符串如下所示:调试%22%3Afalse%2C%22pageOpts%22%3A%7B%22NobidFunSelled%22%3Atrue%2C%22keywords%22%3A%7B%22no-sno-finn-object_类型%22%3A%22private%22%2C%22

我对编程有点陌生,但我发现python没有我需要的速度,所以我切换到go,我正在构建一个刮板,我需要将一个看起来像ASCII格式的字符串转换为json,但我找不到任何关于如何在go中实现这一点的好文档

我需要转换的字符串如下所示:调试%22%3Afalse%2C%22pageOpts%22%3A%7B%22NobidFunSelled%22%3Atrue%2C%22keywords%22%3A%7B%22no-sno-finn-object_类型%22%3A%22private%22%2C%22no-sno-finn-car_make%22%3A%2296%22%2C%22aa-sch出版商%22%3A%22aa-sch-inventory_类型%22%3A%22aa-sch分类%22%2C%22%2C%22aa-sch-car%22aa-country_代码%22%222;%22%222C%22%sno-finn-sno-finn-ad_所有者%22%3A%22false%22%2C%22no sno publishergroup%22%3A%22schibsted%22%2C%22aa-sch-supply_类型%22%3A%22web_桌面%22%2C%22no sno-finn小节%22%3A%22car_用过的%22%2C%22aa-sch-page_类型%22%3A%22object%22%7D


提前谢谢

如评论员所述,您的字符串是URL编码的,可以使用以下方法进行解码:


示例字符串似乎不完整,但最终可以使用将其解码为结构或映射。

ASCII是字符编码,而不是格式。该字符串看起来是URL编码的。一旦解码,它看起来确实是JSON,但它不是一个有效的JSON文档。谢谢大家!就像我说的,我对这个“ASCII格式的字符串”不是什么新鲜事。你从哪里/如何获得这些数据?我有一种感觉,在你试图解码之前,可能有一些不正确的事情发生了。所以,如果我们有更多的背景,我们可能会给你提出更好的建议。我认为这个字符串是用于汽车销售网站的动态广告,这有帮助吗@科斯蒂克斯
package main

import (
  "fmt"
  "net/url"
)

func main() {
  querystr := "debug%22%3Afalse%2C%22pageOpts%22%3A%7B%22noBidIfUnsold%22%3Atrue%2C%22keywords%22%3A%7B%22no-sno-finn-object_type%22%3A%22private%22%2C%22no-sno-finn-car_make%22%3A%22796%22%2C%22aa-sch-publisher%22%3A%22finn%22%2C%22aa-sch-inventory_type%22%3A%22classified%22%2C%22aa-sch-country_code%22%3A%22no%22%2C%22no-sno-finn-section%22%3A%22car%22%2C%22no-sno-finn-ad_owner%22%3A%22false%22%2C%22no-sno-publishergroup%22%3A%22schibsted%22%2C%22aa-sch-supply_type%22%3A%22web_desktop%22%2C%22no-sno-finn-subsection%22%3A%22car_used%22%2C%22aa-sch-page_type%22%3A%22object%22%7D"

  // Parse the URL encoded string.
  plainstr, err := url.QueryUnescape(querystr)
  if err != nil {
    panic(err)
  }
  fmt.Println(plainstr)
  // debug":false,"pageOpts":{"noBidIfUnsold":true,"keywords":{"no-sno-finn-object_type":"private","no-sno-finn-car_make":"796","aa-sch-publisher":"finn","aa-sch-inventory_type":"classified","aa-sch-country_code":"no","no-sno-finn-section":"car","no-sno-finn-ad_owner":"false","no-sno-publishergroup":"schibsted","aa-sch-supply_type":"web_desktop","no-sno-finn-subsection":"car_used","aa-sch-page_type":"object"}

}