FAQ
I have following structure & convert it into JSON by providing key runtime

type Response struct {
        ADRes []AdResponse
}


type WebResponse struct {
     AdID int `json:"adID"`
     AdR string `json:"adR"`
     AdRefreshTIme int `json:"adRefreshTIme"`
}

& JSON is supposed to be
{
     "Dynamic_Ad_Response_ID_1": {
         "adID": 10,
         "AdR": "http://creative.com?id=123",
         "adRefreshTIme": 0
     },
     "Dynamic_Ad_Response_ID_2": {
         "adID": 20,
         "AdR": "http: //creative.com?id=456",
         "adRefreshTIme": 0
     },
     "Dynamic_Ad_Response_ID_3": {
         "adID": 20,
         "AdR": "http: //creative.com?id=456",
         "adRefreshTIme": 0
     }
}

Where the IDs for responses are generated dynamically as suggested by
names. How can this be achieved using standard Json.Marshal in Golang ?

Thanks,
Ajay

--
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/d/optout.

Search Discussions

  • Tamás Gulácsi at Jan 5, 2015 at 3:19 pm
    map[string]WebResponse

    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 5, '15 at 10:59a
activeJan 5, '15 at 3:19p
posts2
users2
websitegolang.org

2 users in discussion

Tamás Gulácsi: 1 post Ajay Bodhe: 1 post

People

Translate

site design / logo © 2021 Grokbase