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
+8.5k Linux/Unix : fatal: the Postfix mail system is already running
+5.3k Golang : How to deal with configuration data?
+39k Golang : How to iterate over a []string(array)
+16.3k Golang : Loop each day of the current month example
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+4.9k HTTP common errors and their meaning explained
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+17.7k Golang : Read data from config file and assign to variables
+7.1k Golang : Transform lisp or spinal case to Pascal case example
+7.8k Golang : Lock executable to a specific machine with unique hash of the machine
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat
+26.9k Golang : Force your program to run with root permissions