Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
qorus
grafana
Commits
e1b2d61c
Unverified
Commit
e1b2d61c
authored
Aug 06, 2019
by
Kyle Brandt
Committed by
GitHub
Aug 06, 2019
Browse files
backend: null.Float NaN -> null for json marshal (#18284)
parent
54f3e873
Changes
1
Hide whitespace changes
Inline
Side-by-side
pkg/components/null/float.go
View file @
e1b2d61c
...
...
@@ -4,6 +4,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"math"
"reflect"
"strconv"
)
...
...
@@ -99,7 +100,7 @@ func (f *Float) UnmarshalText(text []byte) error {
// MarshalJSON implements json.Marshaler.
// It will encode null if this Float is null.
func
(
f
Float
)
MarshalJSON
()
([]
byte
,
error
)
{
if
!
f
.
Valid
{
if
!
f
.
Valid
||
math
.
IsNaN
(
f
.
Float64
)
{
return
[]
byte
(
nullString
),
nil
}
return
[]
byte
(
strconv
.
FormatFloat
(
f
.
Float64
,
'f'
,
-
1
,
64
)),
nil
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment