The general pattern for this is:

1. Create a data structure that reflects the JSON you want.
2. Fill it with data
3. Marshal or Encode

Since you have an example of the JSON you want, putting it through one of 
the tools from Generating Go structs from JSON 
<https://pocketgophers.com/go-structs-from-json/> gives you something like:

type AutoGenerated struct { Status bool `json:"status"` Value struct { 
Types []string `json:"types"` Formula []string `json:"formula"` } 
`json:"value"` }

Now, instead of encoding when iterating though database rows, add the data 
to an instance of that data structure.

After it is filled up, Marshal or Encode the filled data structure to 
produce the JSON you desire.

On Monday, February 26, 2018 at 11:04:29 AM UTC-7, prince antony wrote:
>
>
> can anyone help me to merge labels along with the JSON responses I have my 
> code: https://play.golang.org/p/DB0S4byIHnc      and response: 
> https://play.golang.org/p/y7OOYB1h5z_C     but I don't know to print JSON 
> responses like the below one  (expected output ): 
> https://play.golang.org/p/ejOJeTRqRTM How to print  the expected output
>

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