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
+17.7k How to enable MariaDB/MySQL logs ?
+9.5k Golang : Accessing content anonymously with Tor
+7.3k Golang : File system scanning
+25.3k Golang : Convert uint value to string type
+12k Golang : Clean formatting/indenting or pretty print JSON result
+7.2k Golang : Dealing with postal or zip code example
+12.2k Golang : calculate elapsed run time
+14.4k Android Studio : Use image as AlertDialog title with custom layout example
+14.3k Golang : Simple word wrap or line breaking example
+29.3k Golang : Save map/struct to JSON or XML file
+5.4k Python : Delay with time.sleep() function example
+6.5k Golang : Calculate diameter, circumference, area, sphere surface and volume