This commit is contained in:
huangsimin 2018-12-20 10:53:30 +08:00
parent f63878ff71
commit e5ef67bb47

View File

@ -43,16 +43,17 @@ func (tt *Toutiao) ToDoParser(adstring string) (presult string, err error) {
} }
for _, data := range adlist { for _, data := range adlist {
label := data[0:10]
log.Println("test json -----------------------") log.Println("test json -----------------------")
var v interface{} var v interface{}
// log.Println(gjson.Unmarshal([]byte(data), &v), gjson.Parse(data).Get("app").Exists()) log.Println(label, gjson.Unmarshal([]byte(data), &v), gjson.Parse(data).Get("app").Exists())
data = strings.Trim(data, "\"") data = strings.Trim(data, "\"")
unq, _ := strconv.Unquote("\"" + data + "\"") unq, _ := strconv.Unquote("\"" + data + "\"")
log.Println(gjson.Parse(data).Get("app").Exists()) log.Println(label, gjson.Unmarshal([]byte(data), &v), gjson.Parse(data).Get("app").Exists())
data = unq data = unq
log.Println(gjson.Parse(data).Get("app").Exists()) log.Println(label, gjson.Unmarshal([]byte(data), &v), gjson.Parse(data).Get("app").Exists())
result := gjson.Parse(data) result := gjson.Parse(data)
// log.Println(result.String()) // log.Println(result.String())