hi, i am newer in golang.

i want to marshal pointer value to json.

but, i can't. how can i do that ?

thanks,


package main

import (
"encoding/json"
"fmt"
)

type KV struct {
k string
v string
}

func main() {
kv := []*KV{}

obj := new(KV)
obj.k = "eric"
obj.v = "23"
kv = append(kv, obj)

obj = new(KV)
obj.k = "robot"
obj.v = "32"

kv = append(kv, obj)

fmt.Printf("%d\n", len(kv))
fmt.Printf("%v\n", kv)

b, _:= json.MarshalIndent(kv, "", "  ")
*fmt.Println(string(b)) // <--- not work,,,*
}

output: 

2
[0x1050e140 0x1050e150]*[
  {},
  {}
]*


https://play.golang.org/p/BcsGFjnQt9

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to