Json serialize in golang

package main

import (
    "encoding/json"
    "fmt"
)

type Message struct {
    Name string
    Body string
    Time int64
}

func main() {
    m := Message{"Alice""Hello"1294706395881547000}
    berr := json.Marshal(m)
    if err == nil {
        s := string(b)
        fmt.Println(s)
    }
}

// {"Name":"Alice","Body":"Hello","Time":1294706395881547000}

Comments

Popular posts from this blog

Using SortedDictionary in C#

Vector in C++

Modular Inverse in Bigmod