forked from mirror/go-json
Fix streaming decoder for float value
This commit is contained in:
parent
1d1572fb55
commit
76baae6ce8
|
@ -114,9 +114,6 @@ func (d *floatDecoder) decodeStream(s *stream, p unsafe.Pointer) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !validEndNumberChar[s.char()] {
|
|
||||||
return errUnexpectedEndOfJSON("float", s.totalOffset())
|
|
||||||
}
|
|
||||||
str := *(*string)(unsafe.Pointer(&bytes))
|
str := *(*string)(unsafe.Pointer(&bytes))
|
||||||
f64, err := strconv.ParseFloat(str, 64)
|
f64, err := strconv.ParseFloat(str, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -186,7 +187,6 @@ func nlines(s string, n int) string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func TestDecoder(t *testing.T) {
|
func TestDecoder(t *testing.T) {
|
||||||
for i := 0; i <= len(streamTest); i++ {
|
for i := 0; i <= len(streamTest); i++ {
|
||||||
// Use stream without newlines as input,
|
// Use stream without newlines as input,
|
||||||
|
@ -218,7 +218,6 @@ func TestDecoder(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
func TestDecoderBuffered(t *testing.T) {
|
func TestDecoderBuffered(t *testing.T) {
|
||||||
r := strings.NewReader(`{"Name": "Gopher"} extra `)
|
r := strings.NewReader(`{"Name": "Gopher"} extra `)
|
||||||
|
|
Loading…
Reference in New Issue