Skip to content

Instantly share code, notes, and snippets.

@Olivia5k
Created November 3, 2015 08:54
Show Gist options
  • Save Olivia5k/da7583da1207fa21a615 to your computer and use it in GitHub Desktop.
Save Olivia5k/da7583da1207fa21a615 to your computer and use it in GitHub Desktop.
Example for handling JSON lists with double numerical types
package main
import (
"encoding/json"
"fmt"
)
// JSONDemo is a demo
type JSONDemo struct {
Foo [][2]float64 `json:"foo"`
}
func main() {
data := []byte("{\"foo\": [[1, 1.0], [2, 12.321]]}")
j := JSONDemo{}
json.Unmarshal(data, &j)
fmt.Println(j)
}
// thiderman@dragonwing demo % go run json.go
// {[[1 1] [2 12.321]]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment