Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle invalid float parsing #135

Closed
taowen opened this issue Jul 18, 2017 · 1 comment
Closed

handle invalid float parsing #135

taowen opened this issue Jul 18, 2017 · 1 comment

Comments

@taowen
Copy link
Contributor

taowen commented Jul 18, 2017

package main

import (
	"fmt"
	"log"

	"github.com/json-iterator/go"
)

func test(s string) {
	var err error
	var v interface{}
	err = jsoniter.Unmarshal([]byte(s), &v)
	if err != nil {
		log.Print(err)
		return
	}
	fmt.Println(v)
}

func main() {
	test("--2")   // 2 [Why not error?]
	test("002")   // 2 [Why not error?]
	test("00.2")  // 0.2 [Why not error?]
	test("1e1")   // 10 [Why not float?]
	test("1.0e1") // 10 [Why not float?]
}

reference: gin-gonic/gin#1026

@taowen
Copy link
Contributor Author

taowen commented Jul 18, 2017

should be fixed

@taowen taowen closed this as completed Jul 18, 2017
taowen added a commit that referenced this issue Jul 18, 2017
zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant