Go submit json, get JSON, parse JSON

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Guess you like it.
  • The JSON management mode of the Go language
  • Golang JSON string Remove field
  • Notes Golang JSON
  • Go:json Parsing Library Go-simplejson use
  • Golang 1.6: Database null value encountered JSON and templates (template)
  • Beego under IE tips download json
  • JSON encoding and decoding in Golang
  • Com.google.gson.JsonArray Convert to List
  • JSON in Go

First, submit JSON

reference: 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))} 

Second, get and parse JSON

Cond

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.