Created
November 3, 2015 08:54
-
-
Save Olivia5k/da7583da1207fa21a615 to your computer and use it in GitHub Desktop.
Example for handling JSON lists with double numerical types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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