Created
January 6, 2025 11:30
-
-
Save nikolaydubina/e59c5d73dc678ec241a5b9b3b0616dc5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// when does Go fail to encode JSON? | |
// https://go.dev/play/p/5ptv2ifv8_7 | |
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"math" | |
) | |
type S struct { | |
V float64 `json:"v"` | |
} | |
func main() { | |
var s S | |
s.V = math.Log(-1.0) | |
b, err := json.Marshal(s) | |
fmt.Print(b, err) | |
// [] json: unsupported value: NaN | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment