FAQ
I think that you didn't get my question...this is the code which I
implement so far to convert go object to json string

*func reflection(opts interface{}) { *

* e := reflect.ValueOf(opts)*

* for i := 0; i < e.NumField(); i++ {*



* if e.Field(i).Kind() == reflect.Struct {*


  * fmt.Printf("%q", strings.ToLower(e.Type().Field(i).Name))*


  * fmt.Print(":")*

* fmt.Printf("{\n")*

* reflection(e.Field(i).Interface())*

* }*


  * if e.Field(i).Kind() == reflect.String {*


  * fmt.Printf("%q\n", strings.ToLower(e.Type().Field(i).Name))*

* fmt.Print(":")*

* fmt.Printf("\"%v\"", e.Field(i).Interface())*

* fmt.Printf(",")*


  * }*





* }*






* }The outut is*{"xmlname":{

"space"

:"",

"local"

:"email",


"id"

:"203934839",

"to":{

"email"

:"john@google.com",

"text"

:"John Boris",


"from":{

"email"

:"me@google.com",

"text"

:"My Name",


"subject"

:"Reminder",

"body"

:"You need to get grocery before coming home!",

}


In here I need to omit the part

*"xmlname":{*

*"space"*

*:"",*

*"local"*

*:"email",*


and get the "email" only...How can I do that?


--
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

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 5 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 24, '14 at 10:55a
activeJan 24, '14 at 2:38p
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase