FAQ
I am not sure what you need it for but this might help

package main

import(

     "fmt"

     "encoding/json"

)



type Envelop map[string]interface{}

type message struct {

     Type, Text string

}



func main(){

     var m = make(Envelop)

     m["message"] = message{"error","You can't do that!"}

     j, err := json.Marshal(&m)

     if err != nil {

         fmt.Println(err)

     }

     fmt.Printf("Struct: %s\n", m)

     fmt.Printf("JsonIn: %s\n", j)

     var mm map[string]Envelop

     err = json.Unmarshal(j, &mm)

     if err != nil {

         fmt.Println(err)

     }

     var ss Envelop

     ss = mm["message"]

     fmt.Println("MR: ", ss)

}


On Tuesday, August 17, 2010 4:47:05 AM UTC+3, m wrote:

Does there happen to be a quick conversion between the two? It would
be extremely convenient. Since interfaces only support methods.
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 3, '13 at 8:18p
activeDec 3, '13 at 8:18p
posts1
users1
websitegolang.org

1 user in discussion

RoboTamer: 1 post

People

Translate

site design / logo © 2022 Grokbase