A an array in JSON maps to a slice of a given type in Go i.e. []*Foo, where 
Foo is a struct describing the type of array element.

You can read up more on JSON 
mappings: https://www.programming-books.io/essential/go/a-994-json

You can use https://mholt.github.io/json-to-go/ which is a tool where you 
drop your sample .json file and it generates a Go struct definition for you 
that matches the .json file.

-- kjk


On Monday, March 5, 2018 at 10:28:54 AM UTC-8, Pratik Tayshete wrote:
>
> I have a collection in MongoDB in which there is an array of documents for 
> one value. How can I represent this collection in MongoDB in the form of 
> struct in GO. 
>

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