How to Decode or Unmarshal bi-dimensional array of integers?
Example
package main
import (
"encoding/json"
"fmt"
)
func main() {
var biArray [][]int64
json.Unmarshal([]byte(`[[111,222,333],[444,555,666],
[777,888,999]]`), &biArray)
fmt.Println("Length of Array:",len(biArray))
fmt.Println("\nBi-dimensional Array\n")
for index,element := range biArray{
fmt.Println(index,"=>",element)
}
}
Output
Length of Array: 3
Bi-dimensional Array
0 => [111 222 333]
1 => [444 555 666]
2 => [777 888 999]
Most Helpful This Week
Different ways to validate JSON string
How to get first and last element of slice in Golang?
How to check string contains uppercase lowercase character in Golang?
How to set, get, and list environment variables?
How do you write multi-line strings in Go?
How to collect information about garbage collection?
Golang Read Write Create and Delete text file
How to create a photo gallery in Go?
Dynamic XML parser without Struct in Go
Simple example of Map initialization in Go