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
+13.9k Golang : How to determine if a year is leap year?
+8.8k Golang : Executing and evaluating nested loop in html template
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+8.3k Golang: Prevent over writing file with md5 hash
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+10.1k Golang : Edge detection with Sobel method
+6.3k Golang : Extract sub-strings
+16.8k Golang : read gzipped http response
+12k Golang : Find and draw contours with OpenCV example
+10.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+11k Golang : Create Temporary File
+35.1k Golang : Upload and download file to/from AWS S3