Json deserialize in golang

package main

import (
    "encoding/json"
    "fmt"
)

type Message struct {
    Name string
    Body string
    Time int64
}

func main() {
    var m Message
    s := `{"Name":"Alice","Body":"Hello","Time":1294706395881547000}`
    b := []byte(s)
    err := json.Unmarshal(b, &m)
    if err == nil {
        fmt.Println(m)
    }
}

// {Alice Hello 1294706395881547000}

Comments

Popular posts from this blog

Using SortedDictionary in C#

Vector in C++

Modular Inverse in Bigmod