這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
猜你喜歡
- Go語言的Json管理員模式
- golang json string remove field
- [筆記] Golang JSON
- go: json解析庫go-simplejson使用
- Golang 1.6: 資料庫NULL值遇到JSON和模板(Template)
- beego下ie提示下載json
- golang中json編碼和解碼
- com.google.gson.JsonArray 轉換成list
- Go中的JSON
一、提交json
參考:http://stackoverflow.com/a/24455606
func main() { url := "http://restapi3.apiary.io/notes" fmt.Println("URL:>", url) var jsonStr = []byte(`{"title":"Buy cheese and bread for breakfast."}`) req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) req.Header.Set("X-Custom-Header", "myvalue") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() fmt.Println("response Status:", resp.Status) fmt.Println("response Headers:", resp.Header) body, _ := ioutil.ReadAll(resp.Body) fmt.Println("response Body:", string(body))}
二、擷取並解析json
待續