Skip to content

test case error #245

Closed
Closed
@elvizlai

Description

@elvizlai
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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions