Go言語でhttpリクエストを行った際に帰ってきたjsonを変数に当てはめて使用したいです
pythonではこういうコードになります
python
1# -*- coding: utf-8 -*- 2 3import json 4import requests 5 6def post(): 7 header = { 8 "ContentType" : "application/json", 9 } 10 11 j = {"xxx" : "yyy"} 12 13 request = requests.post( 14 "http://xxxx", 15 headers = header, 16 data = json.dumps(j) 17 ) 18 19 return request.json() 20 #この時帰ってくるjsonが{"code" : 0, "result" : {"id" : 100000}}とする 21 22def post2(id): 23 header = { 24 "ContentType" : "application/json", 25 } 26 27 j = {"id" : id} 28 29 request = requests.post( 30 "http://yyyyy", 31 headers = header, 32 data = json.dumps(j) 33 ) 34 35 return request.json() 36 37 38 39p = post() 40post2(p["result"]["id"]) 41
これをGo言語で再現したいのですがどのように書けばいいのでしょうか
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。