FAQ
Hi,
I am new to this language...I read the xml document and convert it to go
language..now I have the object '''var email Email''.
I have to convert this object to a json string without using encoding/json
package and using *reflect* package.

following is the way how I end up with convert the object to a json string
using reflect package

       s := reflect.ValueOf(&email).Elem()

    typeOfEmail := s.Type()

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

         f := s.Field(i)

         fmt.Printf(" %s : %v\n",

             typeOfEmail.Field(i).Name, f.Interface())

     }



the output which I got is below..

XMLName : { email}

Id : 203934839

To : {{ to} john@google.com John Boris}

From : {{ from} me@google.com My Name}

Subject : Reminder

Body : You need to get grocery before coming home!


But it is not in the standard way for json...Is there any way to correct it?

THANKYOU...

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

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 19, '14 at 10:29a
activeJan 19, '14 at 12:14p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase