rodesousa
1/11/2018 - 10:32 AM

json_unmarshal

package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type Project struct {
	Name  string            `json:"name_with_namespace"`
	Links map[string]string `json:"_links"`
}

type Resp struct {
	Projects []Project `json:"projects"`
}

type Merge struct {
	Merge_requests string `json:"merge_requests"`
	Self           string `json:"self"`
}

func main() {
	resp, _ := http.Get("https://gitlab.com/api/v4/groups/1768437?private_token=ra4HxoNg1adKgVyYURhu")
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	res := Resp{}
	json.Unmarshal(body, &res)
	fmt.Printf("%v", res.Projects[0].Links["merge_requests"])
}