hello everybody,
can anyone help me to get fix this program,it is running correctly but giving wrong output.
I have a struct there and when i run this program it is printing
Output:{todo {0001-01-01 00:00:00 +0000 UTC Assad lunch from home false}}
rather than
Output:{todo {0001-01-01 00:00:00 +0000 UTC Assad lunch from home today false 3 pm}}
below is the code:
package main
import (
“encoding/json”
“fmt”
“time”
)
type ServiceStruct struct {
Todo string json:"todo"
In your typedefinition you specify the JSON keys differently then how you use them in the actual JSON, after fixing them (and omitting some fields that are obviously not a time.Time), it works as expected.
I am pretty sure that whatever you type after json: must match the name in the json string (x). Example, if you type json:creation_dt the json string must contain a field called creation_dt. See below: