package main
import (
"fmt"
"encoding/json"
)
func main() {
var jsonUnmarshal = json.Unmarshal
out := struct {
ID uint64 `json:"id"`
Code string `json:"code"`
Content string `json:"content"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}{}
var jsonVal interface{}
jsonVal = `{
"id": 1,
"code": "CEK",
"content": "CEK",
"createdAt": "2006-01-02T15:04:05Z",
"updatedAt": "2006-01-02T15:04:05Z"
}`
cacheStr, _ := jsonVal.(string)
err := jsonUnmarshal([]byte(cacheStr), &out)
if err != nil{
fmt.Println("ERRORNYA =>", err)
}
fmt.Println("Hello World!", out)
}