添加urlencode
This commit is contained in:
parent
562242ca3f
commit
d82df9df79
@ -30,6 +30,7 @@ func HttpGetEx(url string, params *XObject,
|
||||
if !StrContains(url, "?") {
|
||||
url = url + "?"
|
||||
}
|
||||
url = url + params.ToUrlEncodedStr()
|
||||
client := &http.Client{}
|
||||
request, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
|
14
xobject.go
14
xobject.go
@ -1,6 +1,7 @@
|
||||
package q5
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
@ -171,6 +172,19 @@ func (this *XObject) ToJsonStr() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *XObject) ToUrlEncodedStr() string {
|
||||
if this.IsObject() {
|
||||
u := url.Values{}
|
||||
kvObj := this._val.(map[string]*XObject)
|
||||
for key, val := range kvObj {
|
||||
u.Set(key, val.AsXValue().GetString())
|
||||
}
|
||||
return u.Encode()
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (this *XObject) ToInterface() interface{} {
|
||||
if this._type == XOT_ARRAY {
|
||||
array := this._val.([]*XObject)
|
||||
|
Loading…
x
Reference in New Issue
Block a user