Required json specific key: status -> name
and id
values only
getUrl := "https://www.test.com"
reqTransitionID, err := http.NewRequest("GET", getUrl, nil)
respTransitionID, err := client.Do(reqTransitionID)
if err != nil {
log.Fatal(err)
}
defer respTransitionID.Body.Close()
type Statuskey struct {
Id string `json:"id"`
Name string `json:"name"`
}
type TransitionID struct {
Status Statuskey `json:"status"`
}
jsonData, errrr := ioutil.ReadAll(respTransitionID.Body)
if errrr != nil {
fmt.Println("Error reading JSON data:", errrr)
return
}
fmt.Println(string(jsonData))
var ss TransitionID
json.Unmarshal(jsonData, &ss)
fmt.Println(ss.Status)
fmt.Println(ss.Status.Id)
fmt.Println(ss.Status.Name)
My Json response is :
{
"expand":"demo",
"id":"825",
"self":"TEST",
"key":"TEST",
"fields":{
"status":{
"self":"tst",
"description":"test",
"iconUrl":"test",
"name":"Closed",
"id":"6",
"statusCategory":{
"self":"test",
"id":3,
"key":"done",
"colorName":"green",
"name":"Done"
}
}
}
}