Created
December 7, 2018 02:09
-
-
Save zamicol/8850e9379d03726220ebcba4b5474290 to your computer and use it in GitHub Desktop.
Golang json trailing comma test
This file contains hidden or 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" | |
"strings" | |
) | |
var jsonText = `{ | |
"A":"b", | |
"C":"d", | |
}` | |
type Config struct { | |
A string | |
C string | |
} | |
var c Config | |
func main() { | |
fmt.Println(jsonText) | |
decoder := json.NewDecoder(strings.NewReader(jsonText)) | |
err := decoder.Decode(&c) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(c) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment