Golang encoding/json.Decoder.UseNumber() function examples
package encoding/json
UseNumber causes the Decoder to unmarshal a number into an interface{} as a Number instead of as a float64.
Golang encoding/json.Decoder.UseNumber() function usage examples
Example 1:
decoder := json.NewDecoder(bytes.NewBuffer(jsonData))
decoder.UseNumber()
Example 2:
jsonDecoder := json.NewDecoder(config.inputFile)
jsonDecoder.UseNumber()
var data interface{}
err := jsonDecoder.Decode(&data)
if err != nil {
log.Fatal("Error decoding input: ", err)
}
Reference :
Advertisement
Something interesting
Tutorials
+11.1k Golang : Simple image viewer with Go-GTK
+8.4k Golang : Ackermann function example
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?
+8.7k Golang : Find duplicate files with filepath.Walk
+26.8k Golang : Find files by extension
+12.7k Golang : zlib compress file example
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+8.3k Golang : Implementing class(object-oriented programming style)
+15.2k Golang : How to add color to string?
+14k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+19.6k Golang : Close channel after ticker stopped example