Re: [go-nuts] How to send bytes of data to struct

44 views
Skip to first unread message

Roland Müller

unread,
Sep 29, 2022, 12:54:02 AM9/29/22
to golang-nuts
Following tutorial about usage of encoding/json should address your question.

https://tutorialedge.net/golang/parsing-json-with-golang/

BR,
Roland

Am Sonntag, 25. September 2022 schrieb Vishnu B <vishnu...@gmail.com>:
> I am new to golang, I have a function that receives the JSON data as bytes(data variable) I want to send that data to a struct(Item Struct), When I use the data or string(data) it doesn't accept it. if it uses JSON ({Type:"NETFLOW_V5",ObservationPointID:0,ObservationDomainID:0,TimeReceived:1664011665,IcmpName:""},
>  })  directly it accepts it. How do I use the data variable in the struct? 
> func (d *BigQueryDriver) Send(key, data []byte) error {
>    
>  items := []*Item{
> {Type:"NETFLOW_V5",ObservationPointID:0,ObservationDomainID:0,TimeReceived:1664011665,IcmpName:""},
>  }
> if err := inserter.Put(context.Background(), items); err != nil {
> return err
> }
> return nil
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3d66cd8a-938d-4aab-a027-4c3b3a6f3ad2n%40googlegroups.com.
>
Reply all
Reply to author
Forward
0 new messages