Lets look at the following code snippet:
type Input struct {
Value1 string
Value2 string
Value3 string
Value4 string
Nest
}
type Nest struct {
ID string
}
input := &Input{}
decoder := json.NewDecoder(r.Body)
if err := decoder.Decode(&input); err != nil {
fmt.Printf("something went wrong %v", err)
}
fmt.Printf("Json Input = %+v
", input)
I'm sending the following via cURL:
curl -k -vvv -X POST -d '{"value1":"test", "value2":"Somevalue", "value3":"othervalue", "Nest":{"ID": "12345"}}' http://localhost:8000/endpoint
.. and get the following output:
{Value1:test Value2:Somevalue Value3:othervalue Value4: Nest:{ID:}}
Problem:
I'm not getting a good decoding of the nested struct for some reason. Moreover, I'm not really sure if it's my code or the way I'm calling it.