mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-05-06 05:38:51 +00:00
26 lines
413 B
Go
26 lines
413 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type Config struct {
|
|
IPReportPeriod int `json:"ip_report_period"`
|
|
}
|
|
|
|
func main() {
|
|
jsonData := `{"ip_report_period":30, "unknown_field": 123}`
|
|
var c Config
|
|
|
|
dec := json.NewDecoder(strings.NewReader(jsonData))
|
|
dec.DisallowUnknownFields()
|
|
err := dec.Decode(&c)
|
|
if err != nil {
|
|
fmt.Println("Error:", err)
|
|
} else {
|
|
fmt.Println("Success")
|
|
}
|
|
}
|