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

Add option to unmarshal JSON with UseNumber #16

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

stetra
Copy link

@stetra stetra commented Dec 28, 2020

This PR adds SetUseNumber which enables the use of UseNumber to prevent precision loss when unmarshalling integers.

Example usage:

func main() {
	o := orderedmap.New()
	o.SetUseNumber(true)
	json.Unmarshal([]byte(`{"x":9007199254740993}`), &o)
	x, _ := o.Get("x")
	fmt.Println(x)

	// Output: 9007199254740993
	// If UseNumber is not called, x will be 9007199254740992.000000
}

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

Successfully merging this pull request may close these issues.

2 participants