Created
November 10, 2021 09:31
-
-
Save abstractart/adac1ab4dbcccf243760379e08dccb65 to your computer and use it in GitHub Desktop.
BigIntegers Serialization and Deserialization in Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
jsonStr := "{\"time\":9223372036854775807}\n" | |
var jsonMap map[string]interface{} | |
d := json.NewDecoder(bytes.NewBuffer([]byte(jsonStr))) | |
d.UseNumber() | |
d.Decode(&jsonMap) | |
var bytes bytes.Buffer | |
e := json.NewEncoder(&bytes) | |
e.Encode(jsonMap) | |
fmt.Print(jsonStr) | |
fmt.Print(bytes.String()) | |
fmt.Print(bytes.String() == jsonStr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment