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
Find element in a slice and move it to first position?
How to check if a string contains only letters in Golang?
How to add and update elements in Map?
How to concatenate two or more slices in Golang?
Different ways to validate JSON string
Example: ReadAll, ReadDir, and ReadFile from IO Package
How to get Dimensions of an image type jpg jpeg png or gif ?
How to handle HTTP Get response?
How to check UPPERCASE characters in a string in Golang?
Convert Float32 to Float64 and Float64 to Float32