Skip to content

Instantly share code, notes, and snippets.

@murphysean
Created December 13, 2014 19:26
Show Gist options
  • Save murphysean/c9756ff52ca118e1e2a1 to your computer and use it in GitHub Desktop.
Save murphysean/c9756ff52ca118e1e2a1 to your computer and use it in GitHub Desktop.
go-json-date
package main
import (
"encoding/json"
"fmt"
"reflect"
"time"
)
func main() {
date := time.Now().UTC()
jsonObj := make(map[string]interface{})
jsonObj["somedate"] = date
bytes, err := json.Marshal(&jsonObj)
if err != nil {
panic(err)
}
fmt.Println(string(bytes))
postJsonObj := make(map[string]interface{})
err = json.Unmarshal(bytes, &postJsonObj)
if err != nil {
panic(err)
}
fmt.Println(reflect.TypeOf(postJsonObj["somedate"]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment