Skip to content

Instantly share code, notes, and snippets.

@zamicol
Created December 7, 2018 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zamicol/8850e9379d03726220ebcba4b5474290 to your computer and use it in GitHub Desktop.
Save zamicol/8850e9379d03726220ebcba4b5474290 to your computer and use it in GitHub Desktop.
Golang json trailing comma test
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