Have a try with jsonparser.Get()?

在 2018年8月14日星期二 UTC+8下午6:19:20,nicolas...@yahoo.fr写道:
>
> Hello
>
> I need some assistance to decode a json content 
>
> I tried to use only usefull code to do it but don't success to retrieve 
> the data part of the json result.
>
>     var user struct {
>         Firstname string `json: "firstname"`
>         Lastname string `json: "lastname"`
>         Origin string `"origin"`
>     }
>
>     jsonData := map[string]string{"firstname": "Nic", "lastname": "Raboy"}
>     jsonValue, _ := json.Marshal(jsonData)
>     response, err := http.Post("https://httpbin.org/post";, 
> "application/json", bytes.NewBuffer(jsonValue))
>     defer response.Body.Close()
>     json.NewDecoder(response.Body).Decode(&user)
>     fmt.Println(user)
>
> but this code only map the origin field not the firstname, and lastname 
> part.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to