2021年1月18日星期一

Struct / Array format append to JSON File for GOLANG?

I have a array/struct that constantly printing

for{          results, errz := client.ReadHoldingRegisters(0, 3)          if errz != nil {              fmt.Printf("%v\n", errz)          }            fmt.Printf("results %v\n", results)      }    

Printing output will be like this.

[0 0 0 0 0 0]  [0 0 0 0 0 0]  [0 0 0 0 0 0]  

How do i add it into append it into json format? I'm very new to GOLANG. I printed the type out

fmt.Printf("var1 = %T\n", results)   

Results is []uint8 I need save as int on json format.

Thank you for your time.

https://stackoverflow.com/questions/65783954/struct-array-format-append-to-json-file-for-golang January 19, 2021 at 08:32AM

没有评论:

发表评论