Parse JSON?

Colleagues tell me how to parse JSON
auth_sip_user func(user string,profile string) (crm ) {
 var data crm
 crm_st := "xxxxx"
 client := &http.Client{}
 req, _ := http.NewRequest("GET", ""+crm_st"+", nil)
 req.Header.Add("Accept", "application/json")
 resp, _ := client.Do(req)
 defer resp.Body.Close()
 resp_body, _ := ioutil.ReadAll(resp.Body)
 byt := []byte(resp_body)
 var dat map[string]interface{}
 if err := json.Unmarshal(byt, &dat); err != nil {
 fmt.Println("JSON-ERR")
}
 bytes := []byte(resp_body)
 json.Unmarshal(bytes, &data)
fmt.Println("SIP:",data.sip)
 st := string(resp_body)
fmt.Println("STATUS",resp.StatusCode,"user",user,"ST",st,"DAT",data.sip)
 return data
}


type crm struct {
sip string `json:"sip"`
}

but STATUS 200 user 1000003 ST {"sip":"90ca589e46fb6ea37a3273ec10a1ace0"} DAT

tell me how I can see a line but as a key argument SIP no
June 10th 19 at 16:00
1 answer
June 10th 19 at 16:02
Solution
You have a field in the private structure of the crm (because it is named with a small letter). Accordingly, the marshaling and json unmarshaling it is not involved.
Try this:
type crm struct {
 Sip string `json:"sip"` 
}
thank you - nikita.Stracke commented on June 10th 19 at 16:05

Find more questions by tags Go