Skip to content

test case error #245

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

Closed
elvizlai opened this issue Mar 1, 2018 · 1 comment
Closed

test case error #245

elvizlai opened this issue Mar 1, 2018 · 1 comment

Comments

@elvizlai
Copy link

elvizlai commented Mar 1, 2018

package main

import (
	"strings"
	"github.com/json-iterator/go"
)

var JSON = jsoniter.ConfigCompatibleWithStandardLibrary

type payload struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
}

func main() {
	data := map[string]interface{}{}

	err := call(&data)
	if err != nil {
		panic(err)
	}

	if data["k"] != "v" {
		panic("should equal")
	}
}

func call(rsp interface{}) error {
	raw := `{"code":1,"data":{"k":"v"}}`

	p := payload{Data: rsp}

	decoder := JSON.NewDecoder(strings.NewReader(raw))
	decoder.UseNumber() // looks like there is some wrong in adapter.iter.cfg = cfg.frozeWithCacheReuse()

	err := decoder.Decode(&p)

	return err
}
@taowen taowen closed this as completed in 25fa392 Mar 1, 2018
@taowen
Copy link
Contributor

taowen commented Mar 1, 2018

should be fixed now

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

2 participants